我正在尝试使用POST方法将字典内容发送到服务器
public async Task<T> postConnection(string GETParam, Dictionary<string, string> values, bool isRegistration = false)
{
HttpResponseMessage response;
string responseString;
try
{
using (var client = new HttpClient() { MaxResponseContentBufferSize = 256000 })
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tocken);
var content = new FormUrlEncodedContent(values);
response = await client.PostAsync(url, content);
responseString = await response.Content.ReadAsStringAsync();
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行代码时,它给了我错误
WebException: The request requires buffering data to succeed HttpClient.
我不想使用WebRequest或请求WebClient,我只想使用HttpClient.
一个问题已经存在,当尝试发送一个head request说只是在Xamarin …