C# get 请求携带body需要用到RestSharp,可以通过NuGet获取,但是只有.NetFramework 4.5+版本支持。通过Postman可以测试并生成C#代码
var client = new RestClient("https://orapi-stg.trackmeeasy.com/lomp-ext/sf-express/waybillService/getAgentNo?="); var request = new RestRequest(Method.GET); request.AddHeader("cache-control", "no-cache"); request.AddHeader("Connection", "keep-alive"); request.AddHeader("content-length", "202"); request.AddHeader("accept-encoding", "gzip, deflate"); request.AddHeader("Host", "orapi-stg.trackmeeasy.com"); request.AddHeader("Postman-Token", "56ca6784-0c31-4d41-b5d2-6bdcc047789a,d9873963-5dee-48f1-80d9-d672dede40f4"); request.AddHeader("Cache-Control", "no-cache"); request.AddHeader("Accept", "*/*"); request.AddHeader("User-Agent", "PostmanRuntime/7.11.0"); request.AddHeader("Content-Type", "application/json"); request.AddParameter("undefined", "{ "service": "WaybillService", "api_username": "erptest", "api_key": "78BE1BCAAED1EE08D344F894FBB296D3", "waybill": [{ "orderid": "460692315855", "waybillno": "ML18082997131401_15" }] }", ParameterType.RequestBody); IRestResponse response = client.Execute(request);
参考https://blog.csdn.net/qq_26878363/article/details/86506369