我已将图像转换为字节数组并尝试通过microsoft face api发布,但我一直收到Http400错误请求。我不确定这个问题是否是由我创建的标头或二进制数据引起的。我确实设法以类似的方式发布图像uri,它工作得很好。
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(baseUrl);
client.DefaultRequestHeaders.TryAddWithoutValidation("content-type", "application/octet-stream");
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key",
"MY-KEY");
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/face/v1.0/detect");
request.Content = new ByteArrayContent(bytes);
HttpResponseMessage response = await client.SendAsync(request);
return response;
这是请求,由于某种原因,内容类型不存在。有人可以帮忙解释一下吗?感谢
{Method: POST, RequestUri: 'https://eastus2.api.cognitive.microsoft.com/face/v1.0/detect', Version: 2.0, Content: System.Net.Http.ByteArrayContent, Headers:{ Ocp-Apim-Subscription-Key: MY-Key Content-Length: 141600}}
这是api参考Documentation