当我尝试通过HttpClient发出请求时,我遇到了问题。我得到InnerException“底层连接已关闭:发送时发生意外错误。”。
string encodedCredentials = Convert.ToBase64String(Encoding.UTF8.GetBytes(login + ":" + password));
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", encodedCredentials);
var content = new StringContent(body);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
return await client.PostAsync(new Uri("https://url"), content);
如果我通过Postman提出同样的要求,一切正常。知道什么问题可以吗?