小编jan*_*iss的帖子

当响应头具有位置字段时,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);
  }
 });
Run Code Online (Sandbox Code Playgroud)

通过Fiddler检查响应时,原始数据是:

    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"}
Run Code Online (Sandbox Code Playgroud)

虽然RestSharp将所有respose值显示为null.我认为这与默认的JSonDeserializer有关,它无法解析某些数据.下面是成功解析响应的原始数据:

    HTTP/1.1 200 OK
    Server: nginx
    Date: Wed, 05 Dec 2012 11:28:13 …
Run Code Online (Sandbox Code Playgroud)

c# windows-phone-7 restsharp

3
推荐指数
1
解决办法
5250
查看次数

标签 统计

c# ×1

restsharp ×1

windows-phone-7 ×1