Azure Cognitive服务(Face detection API)返回未找到的资源

时间:2018-01-31 17:46:40

标签: c# azure azure-cognitive-services face-api

我为面部检测认知服务api创建了一个单独的资源,它给出了端点如下,

https://southcentralus.api.cognitive.microsoft.com/face/v1.0

所以在提出如下要求时,

var byteContent = new ByteArrayContent(fileContents);
byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
var response = await _client.PostAsync("detect?returnFaceId=true&returnFaceAttributes=age,gender,smile,facialHair,glasses,headPose,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise", byteContent);
var responseJson = await response.Content.ReadAsStringAsync();

它抛出错误说,

  

未找到资源

1 个答案:

答案 0 :(得分:1)

我认为您需要在基本URI的末尾添加尾部斜杠,否则v1.0将根据this answer被丢弃。

所以:

var client = new HttpClient { BaseAddress = "https://southcentralus.api.cognitive.microsoft.com/face/v1.0/" };