2014-11-17 3 views
0

약 8 개월 전에 SurveyMonkey 응답을 가져 와서 SQL Server에 저장하기 위해 C# 응용 프로그램을 만들었습니다. 응용 프로그램은 문제없이 6 개월 이상 매일 실행되지만 갑자기 금요일 아침에 나는 어떤 요청을받을 수 없습니다. 개발자 사이트에서 정전을 언급하는 내용이 보이지 않아 가능한 코드를 검토했습니다.SurveyMonkey API - 인증 토큰을 찾을 수 없음

이것은 웹 요청을 작성하기 위해 작성한 첫 번째 앱이므로 나쁘게 일할 수도 있습니다. 피들러에서

요청 :

POST https://api.surveymonkey.net/v2/surveys/get_survey_list?api_key=<key hidden> HTTP/1.1 
Authorization: bearer <token hidden> 
Content-Type: application/json 
Host: api.surveymonkey.net 
Content-Length: 146 
Expect: 100-continue 
Connection: Keep-Alive 

{ 
"page": 1, 
"fields": ["title","analysis_url","preview_url","date_created","date_modified","language_id","question_count","num_responses"] 
} 

응답 본체, 피들러에서 :

{"status":1,"errmsg":"Request header \"Authorization\" token not found"} 

C# 코드 :

private JObject SubmitPostRequest(string URIPath, string RequestBody) 
{ 
    using (var webClient = new WebClient()) 
    { 
     // Create URI for POST request to go to. URI varies depending on API method and includes API Key. 
     Uri requestURI = new Uri(APIHost, URIPath + "?api_key=" + APIKey); 

     // Have web client use NT credentials for proxy server 
     webClient.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials; 

     // Specify headers: access token in authorization header, content type 
     webClient.Headers["Authorization"] = "bearer " + AccessToken; 
     webClient.Headers["Content-Type"] = "application/json"; 

     // Create requestBody as byte[] 
     byte[] requestBody = Encoding.Default.GetBytes(RequestBody); 

     // Connect to the URI and send requestBody as a POST command. 
     byte[] postResponse = webClient.UploadData(requestURI, "POST", requestBody); 

     // Update LastConnect 
     LastConnect = DateTime.Now; 

     ++TransactionCounter; 

     // Convert byte[] response to string, parse string and return as JObject. 
     JObject jsonResponse = JObject.Parse(Encoding.Default.GetString(postResponse)); 

     // Evaluate "status" field of jsonResponse. Throw exception if response is not 0. 
     dynamic dyn = jsonResponse; 
     if (dyn.status != 0) 
     { 
      StringBuilder sb = new StringBuilder(); 
      sb.AppendLine("HTTP Post request failed:"); 
      sb.Append("\tstatus: ").AppendLine(dyn.status.ToString()); 
      sb.Append("\terrmsg: ").AppendLine(dyn.errmsg.ToString()); 
      throw new WebException(sb.ToString()); 
     } 

     return jsonResponse; 
    } 
} 
+0

로깅에 어떤 오류가 있습니까? 네가 그걸 가지고 있지 않다면 아무 말도하지 말고. 특정 API를 업데이트하지 않았습니까? 마지막으로 응용 프로그램을 변경 한 시점은 언제입니까? 변경 한 경우 이전 버전으로 롤백하면 어떻게됩니까? 설문 조사 원숭이에 연락하여 변경 사항을 확인 했습니까? – user1666620

+0

오류는 "Authorization token not found"이며 요청이있을 때마다 발생합니다. API를 변경 한 경우 아직 개발자 사이트 (https://developer.surveymonkey.com/)에 대한 업데이트를 게시하지 않았습니다. 응용 프로그램은 매일 실행되며 2014 년 11 월 14 일 목요일 오전 일찍 성공적으로 실행되었습니다. 몇 개월 동안 코드를 변경하지 않았습니다. 설문 조사 원숭이에게 직접 연락하지 않았습니다. 연락하기 전에 StackOverflow에 게시를 요청합니다. –

+1

SurveyMonkey 측에서 아무 것도 변경되지 않았으며 아무도이 오류가 발생하지 않는다고 말할 수 있습니다. 나는 머리글을 벗겨 내고있는 뭔가가 당신의 끝에서 바뀌 었다고 생각합니다. SurveyMonkey로 보내지는 헤더 데이터를 덤프 할 수 있습니까? –

답변

0

그것은 잠시했다, 그러나 나는 연락을 관리 기업의 IT 담당자가 트래픽을 모니터링하여 진행 상황을 확인했습니다. 그들은 프록시 서버에 대한 수정을 구현했으며 결국 모든 것이 다시 작동합니다.