1

I know why it is not recommended to have Http Get with body, see: HTTP GET with request body

But I have a third-party service which is essentially a MongoDB PAAS which lets you query by sending a HTTP GET with body (the filter clause is in HTTP body). It doesn't support the same query via HTTP POST. HTTP GET with body with HttpClient currently gives ProtocolViolationException which complains about the wrong verb.

In my humble opinion, HttpClient should discourage non-standard usages (similar to adding certain headers via TryAddWithoutValidation) but not make them completely impossible. The world is not perfect after all. HttpClient now just stands in my way and the PAAS provider certainly would not change their APIs to suit my http client.

I read numerous related questions here in SO and many answers are talking about why it is BAD to have HTTP GET with body and you should never do it. However, I have no control in my case.

How can I work around this problem with System.Net.Http.HttpClient?

foresightyj
  • 1,836
  • 2
  • 21
  • 40
  • Did you try legacy .NET api like System.Net.WebRequest or System.Net.WebClient? – jlvaquero Sep 12 '17 at 06:59
  • No. I haven't. I guess it might probably work there but I am not very familiar with older http clients in dot net world. But since HttpClient is Microsoft's recommendation now, I prefer a HttpClient solution. – foresightyj Sep 12 '17 at 07:05

0 Answers0