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 Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!