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

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 日

1 投票

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 月 22 日
Thank you very much Prashant, as I understand this is example of setting Data of messageBody as character array or string, can we set same example using structure array? if yes how? is there any documentation or link where it is mentioned that how to set Data of message body for all MATLAB data types mentioned in MATLAB help
Prashanth Ramesh
Prashanth Ramesh 2018 年 10 月 22 日
Sunil
Sunil 2018 年 10 月 23 日
Thank you Prashant

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCall Web Services from MATLAB Using HTTP についてさらに検索

製品

質問済み:

2018 年 10 月 15 日

コメント済み:

2018 年 10 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by