/// <summary> /// RestSharp同步泛型请求 /// </summary> /// <typeparam name="T">类型</typeparam> /// <param name="Url">地址</param> /// <param name="prament">参数</param> /// <param name="methoh">方式</param> /// <returns></returns> public static List <string> ReturnResults <T>(string Url, string prament, Method methoh) where T : new() { var client = new RestSharpClient(Url); var result = client.Execute <List <string> >(new RestRequest("?" + prament, methoh)); return(result); }
/// <summary> /// RestSharp同步请求 /// </summary> /// <param name="Url">接口基地址</param> /// <param name="prament">请求参数</param> /// <param name="method">请求方式</param> /// <returns></returns> public static string ReturnResult(string Url, string prament, Method method) { var client = new RestSharpClient(Url); var result = client.Execute(new RestRequest("?" + prament, method)); return(result.Content); }
public void TestMethod1() { string host = "http://dongqiudi.com"; RestSharpClient client = new RestSharpClient(host); var response = client.Execute("archives/1", RestSharp.Method.GET, request => request.AddQueryParameter("page", "2")); Console.WriteLine(response.Content); }
public static string GetGeographyQuestions() { var req = new JsonRestRequest("api/questions", Method.GET); return(RestSharpClient.Execute(req)); }
public static T GetGeographyQuestions <T>() where T : new() { var req = new JsonRestRequest("api/questions", Method.GET); return(RestSharpClient.Execute <T>(req)); }