2012-11-23 1 views
0

다음 코드는 잘못된 요청 예외를 반환합니다. 여기서 잘못된 것이 있는지 확인하십시오.bing microsofttranslate api를 요청하는 중 badrequest 오류가 발생했습니다.

 string appId = "956vaQc49TdepGpsywiM+BRqfxfgOTeCr/514="; 
    //go to http://msdn.microsoft.com/en-us/library/ff512386.aspx to obtain AppId. 
     string text = "translate this"; 
     string language = "en"; 
     System.Uri uri = new Uri("http://api.microsofttranslator.com/v2/Http.svc/Speak?&appId=" + appId + "&text=" + text + "&language=" + language); 

     try 
     { 
      HttpClient client = new HttpClient(); 
      HttpResponseMessage response = await client.GetAsync(uri); 
      response.EnsureSuccessStatusCode(); 
      Stream responseBody = await response.Content.ReadAsStreamAsync(); 
      // meTextToSpeeach.Source = uri; 
      string strResponse; 
      using (Stream responseStream = responseBody) 
      { 
       using (StreamReader sr = new StreamReader(responseStream, System.Text.Encoding.Unicode)) 
       { 
        strResponse = sr.ReadToEnd(); 
       } 
      } 

     } 
     catch (Exception) 
     { 


     } 

답변

0

매개 변수 (appId, text, language)는 인코딩하지 않습니다. "..."+ WebUtility.UrlEncode (appId) + "..."...

을 수행해야합니다.
관련 문제