0

I'm trying to create a person-group using MS Cognitive face API but I keep getting the error message "The remote server returned an error: (404) Not Found.". Below is my source code. Would be glad if anybody could help me solve this.

using (var q3 = new WebClient())
{
    q3.Headers.Add(HttpRequestHeader.ContentType, "application/json");
    q3.Headers.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
    string url = "https://eastus.api.cognitive.microsoft.com/face/v1.0/persongroups/identificationapp2";
    string json = "{\"name\":\"" + "TEST" + "\", \"userData\":\"" + "TEST INFORMATION" + "\" }";
    string str = q3.UploadString(url, json);
}
Nicolas R
  • 13,812
  • 2
  • 28
  • 57
mparra
  • 1

1 Answers1

0

If you look at the documentation for your region for this Create PersonGroup method here, you must do a PUT operation:

API description

In your code you are doing the following:

string str = q3.UploadString(url, json);

Which is doing a POST, not a PUT (see doc here). To do a PUT, you can specify the method:

string str = q3.UploadString(url, "PUT", json);

PS: you can also use HttpClient, see why here on StackOverflow

Nicolas R
  • 13,812
  • 2
  • 28
  • 57