我为面部检测认知服务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();
它抛出错误说,
未找到资源
答案 0 :(得分:1)
我认为您需要在基本URI的末尾添加尾部斜杠,否则v1.0
将根据this answer被丢弃。
所以:
var client = new HttpClient { BaseAddress = "https://southcentralus.api.cognitive.microsoft.com/face/v1.0/" };