/// <summary> /// RestSharp异步请求 /// </summary> /// <typeparam name="T">List<string></typeparam> /// <param name="Url">请求地址</param> /// <param name="prament">请求参数</param> /// <param name="methoh">请求方式(GET, POST, PUT, HEAD, OPTIONS, DELETE)</param> /// <param name="callback">回调函数</param> /// <returns>异步调用回调函数</returns> public static void ReturnResult <T>(String Url, String prament, Method methoh, Action <IRestResponse <T> > callback) where T : new() { var client = new RestSharpClient(Url); LogHelper.Info("请求地址:" + Url + prament); client.ExecuteAsync <T>(new RestRequest(prament, methoh), callback); }
/// <summary> /// RestSharp同步请求 /// </summary> /// <param name="Url">请求地址</param> /// <param name="prament">请求参数</param> /// <param name="methoh">请求方式(GET, POST, PUT, HEAD, OPTIONS, DELETE)</param> /// <returns>返回的是List<string>数据</returns> public static List <String> ReturnResults(String Url, String prament, Method methoh) { var client = new RestSharpClient(Url); LogHelper.Info("请求地址:" + Url + prament); 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="methoh">请求方式(GET, POST, PUT, HEAD, OPTIONS, DELETE)</param> /// <returns>返回的是string数据</returns> public static String ReturnResult(String Url, String prament, Method methoh) { var client = new RestSharpClient(Url); LogHelper.Info("请求地址:" + Url + prament); var result = client.Execute(new RestRequest(prament, methoh)); return(result.Content);//返回的字符串数据 }