c# RestClient 请求接口
引用 RestSharp.dll
// 人员信息
RestClient client = new RestClient("url");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("appId", appId);
request.AddHeader("signaTure", signaTure);
request.AddHeader("Content-Type", "application/json");
var body = @"{""createTimeStart"":"""",""createTimeEnd"":"""",""updateTimeStart"":"""",""updateTimeEnd"":"""",""pageSize"":9999999}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
JObject obj = (JObject)JsonConvert.DeserializeObject(response.Content);
request.AddHeader("routeId", routeId);
string jsonData = "{ \"conditions\":{ \"requestname\":\"" + "" + "\",\"workflowIds\":\"" + workflowId + "\"},\"pageNo\":\"" + 1 + "\",\"pageSize\":\"" + 1000 + "\",\"workId\":\"" + workcode + "\",\"appId\":\"" + appId + "\"}";
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(jsonData);
参数为对象
var client = new RestClient(esbUrl);
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("FactoryID",workcode);
request.AddParameter("LineID", "aa");
request.AddParameter("ProjectID", "小米汽车项目");
request.AddParameter("WorkShopID", "小米汽车项目");
IRestResponse response = client.Execute(request);
参数为json对象
var client = new RestClient(esbUrl);
var request = new RestRequest(Method.POST);
string jsonData = "{ \"conditions\":{ \"requestname\":\"" + "" + "\",\"workflowIds\":\"" + workflowId + "\"},\"pageNo\":\"" + 1 + "\",\"pageSize\":\"" + 1000 + "\",\"workId\":\"" + workcode + "\",\"appId\":\"" + appId + "\"}";
request.AddParameter("inStr", jsonData);
RestSharp.dll 下载地址
https://download.csdn.net/download/weixin_42020830/86726750
————————————————
版权声明:本文为CSDN博主「glad_666」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42020830/article/details/127101002