GET request with body
12 views (last 30 days)
Austin O'Connell on 13 Oct 2020
Is it possible to send a GET request that includes a body in the RequestMessage?
I've tried the following code
request = RequestMessage;
request.Body = MessageBody;
request.Body.Data = struct('Name1', 'value1', 'Name2', 'value2');
request.Method = 'get';
uri = URI('http://127.0.0.1/my/api');
[response, completedReq, history] = send(request, uri);
Every time I try this, I get the following response:
Warning: Body unexpected in message using request method GET.
Despite this just being a warning, my web request seems to never even send. Suppressing warnings by doing warnings('off') didn't make a difference.
Additionally, I have tried using webread and webwrite instead of send, but have not had any luck there as well.
Any ideas on how to get this working?
Abhisek Pradhan on 18 Oct 2020
As per my knowledge a request message containing a Body property normally uses a method such as 'PUT' or 'POST. But this is not something which is enforced. Try using POST or PUT and see if it works.