How to introduce a body (json text) in webread function?
조회 수: 14 (최근 30일)
이전 댓글 표시
Dear,
I am looking for reading data from a private server, for this i have a json text as :
text_json = [''...
'{'...
' "fromDate": "2023-08-01",'...
' "toDate": "2023-08-02" '...
'}'...
''];
For information this information can be used in Postman application for manual data extraction.
options = weboptions('RequestMethod', 'POST', 'HeaderFields', headers);
And i need to applique to the webread function as :
data = webread(URL,text_json,options);
I am not sure about the good way for solve this issues.
Best Regards.
댓글 수: 0
답변 (1개)
Jeremy Hughes
2024년 1월 4일
You can use WEBWRITE for POST requests: https://www.mathworks.com/help/matlab/ref/webwrite.html
opts = weboptions("ContentType","application/json")
webwrite(url,data,opts) % data is the content of the BODY, be sure to match the content type
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 JSON Format에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!