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

6 vues (au cours des 30 derniers jours)
Sunil
Sunil le 15 Oct 2018
Commenté : Sunil le 23 Oct 2018
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?

Réponse acceptée

Prashanth Ramesh
Prashanth Ramesh le 18 Oct 2018
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 commentaires
Prashanth Ramesh
Prashanth Ramesh le 22 Oct 2018
Sunil
Sunil le 23 Oct 2018
Thank you Prashant

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Call Web Services from MATLAB Using HTTP dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by