MATLAB: How to look at the payload of a webwrite response when the response is a 400 or other error

MATLAB

How do I look at the payload of a "webwrite" response when the response is a 400 or other error? It throws a MATLAB error, but doesn't display any of the error messages the server sent back as payload.
My code looks something like this:
json_request = struct('a', nan);
json_response = webwrite('http://localhost:8000/reports/', json_request, ...
weboptions('MediaType', 'application/json', 'RequestMethod', 'post'))

Best Answer

So basically, you can't get the payload of an error response using "webwrite". However you can get this using the HTTP interface. It might look something like:
import matlab.net.http.*
r = RequestMessage;
resp = r.send(url); %replace url with your target address
show(resp)