问题
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