2012-12-05 5 views
3
을 갖는 널 (null) 값을 리턴

내 나머지 요청 : 들러 통해 응답 의하면RestSharp 응답 헤더 위치 필드

RestSharp.RestClient uplClient = new RestSharp.RestClient(); 
RestSharp.RestRequest request = new RestSharp.RestRequest(IMAGE_UPLOAD_URI, Method.POST); 
request.AddParameter("user", USER_HASH); 
request.AddParameter("apikey", API_KEY); 
request.AddFile("Filedata", file, "test.jpg","image/jpeg"); 

uplClient.ExecuteAsync(request, (response) => 
{ 
    callback(response.Content, null); 

    if (response.StatusCode == HttpStatusCode.OK) 
    { 
    MessageBox.Show("Upload completed succesfully...\n" + response.Content); 
    } 
    else 
    { 
    MessageBox.Show(response.StatusCode + "\n" + response.StatusDescription); 
    } 
}); 

, 원시 데이터는 :

RestSharp가 null 모든 respose 값을 나타내고 있지만
HTTP/1.1 302 Moved Temporarily 
    Server: nginx 
    Date: Wed, 05 Dec 2012 11:35:57 GMT 
    Content-Type: text/javascript;charset=utf-8 
    Connection: keep-alive 
    Location: file:///Applications/Install/8014A556-A76A-4294-B375-6E3668177CCA/Install/?errorNr=0&picUploadId=1007501 
    Content-Length: 423 

    {"ok":true,"error":false,"imageIcon":0,"uid":1287837,"tmpId":1007501,"url":"http:\/\/i1.ifrype.com\/tmp\/10\/1007501.jpg","urlIcon":"http:\/\/i1.ifrype.com\/tmp\/10\/i_1007501.jpg","urlSmall":"http:\/\/i1.ifrype.com\/tmp\/10\/sm_1007501.jpg","urlMiddle":"http:\/\/i1.ifrype.com\/tmp\/10\/nm_1007501.jpg","urlLarge":"http:\/\/i1.ifrype.com\/tmp\/10\/l_1007501.jpg","urlGM":"http:\/\/i1.ifrype.com\/tmp\/10\/ngm_1007501.jpg"} 

. 나는 이것이 데이터의 일부를 파싱 할 수없는 기본 JSonDeserializer를 가지고 있다고 가정한다. 아래는 성공적으로 파싱 된 응답을 가진 원시 데이터입니다.

HTTP/1.1 200 OK 
    Server: nginx 
    Date: Wed, 05 Dec 2012 11:28:13 GMT 
    Content-Type: text/javascript;charset=utf-8 
    Connection: keep-alive 
    Content-Length: 1015 

    {"users_login":{"login":{"apikey":"9073902hjkwehfweiufy34","img":"http:\/\/i7.ifrype.com\/profile\/287\/837\/v1341214689\/sm_12858487837.jpg"}}} 

http 상태 또는 위치 값 또는 다른 이유로 인해 발생할 수 있습니까? 이것에 대해 정말 좌절 임,

답변

6

나는이 게시물에 내 문제에 대한 해결책을 발견 :(성공하지 allmost 하루 spet : https://stackoverflow.com/a/1028141/1341545

은 결국 당신이 Restsharp 클라이언트를 설정해야합니다 있도록 속성을 "false"로 인, followRedirects를 클라이언트 요청 헤더가 위치를 재 무시합니다.

RestSharp.RestClient uplClient = new RestSharp.RestClient(); 
uplClient.FollowRedirects = false; 

하면 트릭

을 수행