ASPNET - Cannot send a content-body with this verb-type GET
ASPNET - Cannot send a content-body with this verb-type GET
I am trying a send a GET request with a content-body, I have the following error :
Cannot send a content-body with this verb-type
I use HttpWebRequest.
A Exception start when the method Http.GetRequestStream() is requested.
I read another related thread on Stackoverflow but I don't read good answer.
I can't change a verb because i use a service web owner.
Can you help me ?
Best Regards
Arnaud
I assume this is the other thread you mentioned stackoverflow.com/questions/253549/… , as the answers to the question say you can't set a body on a GET request. If the endpoint you are calling really expects a body on GET, then you need to change the endpoint.
– andynormancx
Sep 18 '18 at 12:21
You have to use a
POST rather than a GET. Parameters needed for a GET are usually passed in the query string, or as a header, but this should not be used for putting entire amounts of data. You're essentially POSTing information to the API which it should then store– ColinM
Sep 18 '18 at 12:21
POST
GET
GET
Possible duplicate of How do I use HttpWebRequest with GET method
– andynormancx
Sep 18 '18 at 12:22
One thing you should check is whether the endpoint you are calling supports the
X-HTTP-Method-Override header. If that was the case you could make a POST request, with a body, but tell it to treat it as a GET. It is unlikely however that an endpoint expecting a body on a GET will have that sort of support– andynormancx
Sep 18 '18 at 12:27
X-HTTP-Method-Override header
POST
GET
GET
0
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy
Please, can you send a sample of code. It's difficult to help you without it
– OrcusZ
Sep 18 '18 at 12:13