The request requires buffering data to succeed HttpClient
Unfortunately
var response = await client.PostAsync(url, content);
Downloads entire response before finishing, so it does not use any buffering. The only alternative is to use,
var request = new HttpRequestMessage(url);
request.Content = content;
var response = await client.SendAsync(request,
HttpCompletionOption.ResponseHeadersRead);
HttpCompletionOption.ResponseHeadersRead
option makes HttpClient
return from SendAsync
just after downloading headers. And you can await on reading the content.
Based on the Mono source code for HttpWebRequest, it looks like the server is issuing a redirect, and HttpWebRequest (used under the covers by HttpClient) is not handling that.
I'm not exactly sure what version of the Mono source is being used, but this looks like a likely candidate: https://github.com/mono/mono/blob/cc3f4c60379c3839dd4259e171bb4539d21f2157/mcs/class/System/System.Net/HttpWebRequest.cs
That version has a "throw" at line 1005 in HttpWebRequest.EndGetResponse, which matches the exception stack you're seeing. The string in the exception, "The request requires buffering data to succeed" comes from HttpWebRequest.Redirect.
The next step would be to use Fiddler (or similar) to replicate the exact POST message the Xamarin client is attempting to see the response it gets from the server.
For the same question you have linked in making a head request , please see the below link where the solution is given one of them in xamarin forums, who had the same issue in making a POST request (200) to Google url.
The resolution in that case was changing the URL to an actual page and not a redirect.
Here 's the link Solution for the issue
Hope it helps.
Is this happening on iOS and/or Android?
I would try changing the HttpClient handler to be the native handler. This solves a lot of problems ranging a lot of topics (TLS is a big one). For iOS, use the NSUrlSession handler and for Android, try the AndroidClientHandler. You should be able to use HttpClient for everything with Xamarin.