问题:Xamarin + RestSharp 请求返回空 JSON

我正在尝试从 Flask-RESTful API 获取 JSON,而不是:

  [
   [
    {
      "c_t": [],
      "imie": "test",
      "login": "test2",
      "nazwisko": "test3",
      "oferty": [],
      "password": "passpass",
      "user_id": 13,
      "u_t": []
    }
  ],
  {}
]

我得到空字符串作为 response.Content。这是我的代码:

var client = new RestClient("https://SERVER-IP");
var request = new RestRequest("/users", Method.GET);

request.AddHeader("Content-Type", "application/json");

client.ExecuteAsync(request, response =>
{
 RunOnUiThread(delegate
 {
    var responseC = response.Content;

    Toast.MakeText(this, responseC, Toast.Length.Long).Show();
 });
});

解答

使用 http 而不是 https ;) 这就是为我们解决的问题。

Logo

学AI,认准AI Studio!GPU算力,限时免费领,邀请好友解锁更多惊喜福利 >>>

更多推荐