In MATLAB Analysis, how do I set HTTPOptions to mirror webwrite options?
1 次查看(过去 30 天)
显示 更早的评论
I'm trying to recreate an HTTP POST in MATLAB analysis which is workign in Postman, so that I can use the data from the Huawei SolarFusion Northbound API in my project.
The login endpoint I'm using requires consumers to inspect the headers in the response. It returns 17 headers, one of which is an xsrf-token with a correspoding value I need to extract.
I tried using MATLAB webwrite function, the call is successful when I set weboptions as:
options = weboptions('MediaType','application/json','RequestMethod','post','CertificateFilename', '');
...
S = webwrite(url, data, options);
display (S,'look at this');
, but I couldn't find headers in the return object, S, the display output is:
struct with fields:
data: []
success: 1
failCode: 0
params: [1×1 struct]
message: []
So I am attempting to use native HTTP send(request,uri,httpOptions) but am getting:
ResponseMessage with properties:
StatusLine: 'HTTP/1.1 500 Internal Server Error'
StatusCode: InternalServerError
Header: [1×17 matlab.net.http.HeaderField]
Body: [1×1 matlab.net.http.MessageBody]
Completed: 0
Great news that the headers are there, but I cannot make the call succeed.
I am using HTTPOptions and this is tricky to figure out the equivalent settings to webwrite options. I believe HTTPOptions of ('Authenticate',false) is equivalent to weboptions of ('CertificateFilename', '') and this is a possible cause of the error.
uri = url;
httpOptions = matlab.net.http.HTTPOptions('Authenticate',false);
[response,completedrequest,history] = send(request,uri,httpOptions);
display(response, ' Response ');
2 个评论
Thomas Anvidalfarei
2024-1-10
Hello,
I am interested in analysing my PV data using Matlab. Since I am a hobby programmer and am not familiar with API interfaces, I download the Excel files from the fusion solar portal every month and import them.
Since I assume that you have created the code for the interface, I would like to ask if you would make it available to us. Of course with anonymised login data.
Thanks
Thomas
采纳的回答
更多回答(0 个)
社区
更多回答在 ThingSpeak Community
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!