how to assign data to matlab.net​.http.Mess​ageBody object?

조회 수: 10 (최근 30일)
Sunil
Sunil 2018년 10월 15일
댓글: Sunil 2018년 10월 23일
I am trying to assign data to matlab.net.http.MessageBody object, and 'Content-Type' set to 'application/x-www-form-urlencoded; charset=utf-8', while creating httpclient for a server. does anybody know or can give examples about how to assign data to matlab.net.http.MessageBody object? I want to assign in format of name value pair since I need to assign userName and Password?

채택된 답변

Prashanth Ramesh
Prashanth Ramesh 2018년 10월 18일
You should be able to assign data to matlab.net.http.MessageBody in the following way:
>> request = matlab.net.http.RequestMessage;
>> request.Method = matlab.net.http.RequestMethod.POST;
>> request.Body = matlab.net.http.MessageBody('username=myusername&password=mY_S3cr3t_pA55w0rd!');
>> request.Header = matlab.net.http.field.ContentTypeField('application/x-www-form-urlencoded;charset=utf-8');
>> response = request.send('https://my_url/login')
  댓글 수: 3
Sunil
Sunil 2018년 10월 23일
Thank you Prashant

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Web Services from MATLAB Using HTTP에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by