1

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

Habeeb
  • 7,601
  • 1
  • 30
  • 33
snopims
  • 33
  • 4
  • 6
    Please, can you send a sample of code. It's difficult to help you without it – OrcusZ Sep 18 '18 at 12:13
  • I assume this is the other thread you mentioned https://stackoverflow.com/questions/253549/how-do-i-use-httpwebrequest-with-get-method , 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
  • 3
    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
  • 1
    Possible duplicate of [How do I use HttpWebRequest with GET method](https://stackoverflow.com/questions/253549/how-do-i-use-httpwebrequest-with-get-method) – andynormancx Sep 18 '18 at 12:22
  • Possible duplicate of https://stackoverflow.com/questions/52307420/postman-send-body-content-in-get-method#comment91562507_52307420 . – mjwills Sep 18 '18 at 12:23
  • 1
    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
  • I cant' use POST because the endpoint wait GET. I can't change the endpoint. – snopims Sep 19 '18 at 06:17

0 Answers0