2017-03-14 2 views
0

저는 얼굴 인식 프로젝트를 진행 중이므로 Microsoft Azure인지 서비스와 함께 놀고 있습니다. 내가 6 개월 전에 이것을 못살게 굴 것이라고 생각한 자기 자신의 Json Malformed synax를 교정 할 수없는 이유가 확실치 않습니다. 나는 'Person Group API'를 호출하기 위해 그룹 이름을 만들고 싶다. 그리고 MS 예제를 따라 할 때마다 API 테스트 콘솔에서 오류가 발생하지만 여기서는 MS 사이트에서 빌려온 코드 예제가 없다.Microsoft Face API 1.0 오류 리소스를 찾을 수 없습니다.

{ "error": { "code": "ResourceNotFound", "message": "요청한 리소스를 찾을 수 없습니다." }}

및 콘솔 모드에서 실행되는 코드 :

static async void CreateGroup() 
     { 
      string key1 = "YourKey"; 
      // azure the one should work 
      var client = new HttpClient(); 
      var queryString = HttpUtility.ParseQueryString(string.Empty); 

      // Request headers 
      client.DefaultRequestHeaders.Add 
      ("Ocp-Apim-Subscription-Key", key1); 

     var uri = "https://westus.api.cognitive.microsoft.com/face/v1.0/ 
     persongroups/{personGroupId}?" + queryString; 

     HttpResponseMessage response; 

     // Request body 
     string groupname = "myfriends"; 

     string body = "{\"name\":\"" + groupname + ","+ "\"}"; 
     // Request body 
     using (var content = new StringContent 
     (body, Encoding.UTF8, "application/json")) 
     { 

      await client.PostAsync(uri, content) 
       .ContinueWith(async responseTask => 
       { 
        var responseBody = await responseTask.Result 
        .Content.ReadAsStringAsync(); 
        Console.ForegroundColor = ConsoleColor.Yellow; 
        Console.WriteLine("Response: {0}", responseBody); 
        Console.WriteLine(""); 

        Console.WriteLine("Group Created.... "); 
        Console.WriteLine("Hit ENTER to exit..."); 
        Console.ReadKey(); 
       }); 

      response = await client.PutAsync(uri, content); 
      Console.WriteLine("what is this {0}", response.ToString()); 
      Console.ReadKey(); 

     }// end of using statement 


    }// end of CreateGroup 
    #endregion 

내가 여기 추측이다하지만 난 다시는 내 JSON 잘못된 생각 나는 다시 잘못이 시간에 뭐하는 거지 난 그냥 모르는 , 사이트에 따라 내가 ms로 보내야하는 필드 이름은 'name'입니다. 'userData에'는이

어떤 지원이 가장

답변

3

요청의 URL이 {personGroupId}이 곳의 장소에서 그룹 ID를 지정해야합니다 여기

감사를 환영합니다 선택 사항입니다. spec 당 그룹 ID는 다음과 같아야합니다.

사용자 제공 personGroupId는 문자열이어야합니다. 유효한 문자는 숫자, 영문자는 소문자, '-'및 '_'입니다. personGroupId의 최대 길이는

(64)는 또한, HTTP 동사 당신이 client.PostAsync 요청을 한 반면, PUT 할 필요가있다. 따라서 이것을 client.PutAsync으로 변경해야합니다.

Microsoft는 작동중인 C# 코드를 찾을 수있는 Face API의 C# 용 클라이언트 라이브러리를 제공합니다.