1.postman测试ok
2.C#代码
public static async Task<string> testGetToken(string URL, string param){string responseBody = "eee";//using (var clientHandler = new HttpClientHandler()){ var handler = new HttpClientHandler();handler.ServerCertificateCustomValidationCallback = delegate { return true; };using (var client = new HttpClient(handler)){try{ HttpContent content = new StringContent(param);content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");HttpResponseMessage response = await client.PostAsync(URL, content);//改成自己的response.EnsureSuccessStatusCode();//用来抛异常的responseBody = await response.Content.ReadAsStringAsync();//Console.WriteLine(responseBody);}catch (Exception e){Log.Logger.Error($" 获取token异常 {e.Message}");}}}return responseBody;}
3.调用方法
string URL = $"https://192.168.111.111:1111/BSAPI/V1/ProductionData/getToken?machineNO=sponge01&key=28853ACB-FA6A-47A5-9B22-9578880290BD";string result = await HttpClientHelper.testGetToken(URL, "");
4.测试后返回的结果