Restsharp not giving any response

99封情书 提交于 2019-12-11 15:34:33

问题


I am developing an Android app in Xamarin.Android and I want to access a Web API (hosted on local IIS) using RestSharp. When I run the app it doesn't give any result nor give any error.

Here is my code

var client = new RestClient("http://localhost:8066/Student/?id=193");
            var request = new RestRequest("", Method.GET);
            IRestResponse response = client.Execute(request);
            var content = response.Content;
            Console.WriteLine("Response: " + content);

回答1:


Follow the documentation, when creating a RestClient you should just provide the base URL.

var client = new RestClient("http://localhost:8066");
var request = new RestRequest("/Student", Method.GET);
request.AddParameter("id", "193");
IRestResponse response = client.Execute(request);
var content = response.Content;
Console.WriteLine("Response: " + content);


来源:https://stackoverflow.com/questions/20068974/restsharp-not-giving-any-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!