Http接口post类型中request body的row中传参调用
程序员文章站
2022-03-20 08:23:59
...
Postman中调用如下
Restsharp 调用
public static void RestSharpRun()
{
RestClient client = new RestClient("http://InterfaceUrl")
{
Timeout = 600000
}
RestRequest request = new RestRequest("yourMethod",Method.POST);
request.AddHeader("xxx", "xxx");
Params paramModel = new Params
{
iMethodName = "xxxx",
startFltDatePek = "2020-01-10 15:45:26",
endFltDatePek = "2020-01-11 15:45:26"
};
string jsonPar = JsonConvert.SerializeObject(paramModel);
request.AddJsonBody(jsonPar); //参数在request body 的row中
var content = client.Execute(request).Content;
if (!string.IsNullOrEmpty(content))
{
T result = JsonConvert.DeserializeObject<T>(content);
if (result.Body != null)
{
// 处理result.Body
}
}
}
END |
下一篇: php针对日期操作与流程控制的方法