weboptions adding additional header parameters/parameters to HTTP POST request
17 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I am trying to connect to an API where I need to pass the Authorization token. The authorization is part of the header of HTTP POST.
Authorization: abc230
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 2
Content-Type: application/json
In Matlab, 'weboptions' function/object can have 'Username' and 'Password' as named fields. It also mentions 'KeyName' and 'KeyValue' as additional fields that can be passed.
I wanted to clarify if the following command will make things consistent with the API header requirement:
weboptions('RequestMethod','POST','ContentType', 'json','Timeout',60,'KeyName','Authorization','KeyValue','abc230')
This is my output
CharacterEncoding: 'auto'
UserAgent: 'MATLAB 8.5.0.197613 (R2015a)'
Timeout: 60
Username: ''
Password: ''
KeyName: 'Authorization'
KeyValue: 'abc230'
ContentType: 'json'
ContentReader: []
MediaType: 'application/x-www-form-urlencoded'
RequestMethod: 'post'
Thanks,
Vaibhav
0 件のコメント
採用された回答
Morrie Gasser
2017 年 2 月 6 日
Prior to R2016b, KeyName and KeyValue let you add one custom header field to the request. In R2016b, weboptions now allows you to specify an arbitrary number of header fields using the 'HeaderFields' option.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Web Services についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!