3

As explained here it is technically allowed for GET request to contain a request body even though it is not recommended.

Unfortunateley I have to consume an API I have not control over that requires me to send data in the body. It works perfectly fine in curl but I cannot get it to work in c#.

As other threads explain it does not seem to be possible to do that using WebRequest/WebClient as this will throw Cannot send a content-body with this verb-type. The often referred to workaround to use POST instead of GET is unfortunateley not possible with the API.

Are there any existing libraries that extend the .net classes in a way to allow this scenario? Implementing this myself on top of TcpClient is over my head.

Community
  • 1
  • 1
leepfrog
  • 351
  • 1
  • 8
  • 23
  • 1
    Your "technically allowed" isn't quite correct; the client is technically allowed to send a body with GET, but the server is not allowed to pay it any attention. Not much help to you if you have to deal with a server with such a bug. I wonder if maybe the simplest (for non-trivial values of "simplest" solution would be to create a proxy program that replaced "PUT" with "GET" in passing the request on to the server. – Jon Hanna May 18 '15 at 11:08

0 Answers0