Webread - How to get Web Response Code ?
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi,
I am using webread function to read web contents to my matlab program. I also would like to receive web response code, for example, 401, if web connection is wrong.
Webread function does not return this web response code. Does anyone know how to do this?
댓글 수: 0
답변 (1개)
Rahul
2025년 6월 25일
While 'webread' does not expose the response metadata like status code or headers, you can consider using the 'matlab.net.http' package which would give control over http request and response.
Here is an example:
import matlab.net.*
import matlab.net.http.*
% Define the URI
uri = URI('https://httpbin.org/basic-auth/user/passwd');
% Create a GET request message
request = RequestMessage;
response = request.send(uri);
% Display the status code
disp("Status code: " + response.StatusCode)
The following MathWorks documentations can be referred to know more:
'matlab.net.http.RequestMessage Class': https://www.mathworks.com/help/matlab/ref/matlab.net.http.requestmessage-class.html
Thanks.
댓글 수: 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!