Sajeetharan
Sajeetharan

Reputation: 222722

Azure Cognitive service (Face detection API) returns resource not found

I have created a separate resource for face detection cognitive service api and it gives the endpoint as follows,

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

so while making request like below,

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();

it throws an error saying,

Resource Not Found

Upvotes: 1

Views: 779

Answers (1)

orhtej2
orhtej2

Reputation: 2165

I believe you need to add trailing slash to end of your base URI otherwise the v1.0 will be discarded as per this answer.

So:

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

Upvotes: 2

Related Questions