[英]Get request failed on RestSharp and works on postman
我在 postman 和 RestSharp 上做了一个简单的调用。 相同的请求在 RestSharp 上收到了错误的响应。
Url
https:PATH/rest/ids?request_id=6d3a4f28-633c-440c-8631-905710e9302d
Rest 锐码:
var client = new RestClient("https://PATH/rest/ids?request_id=6d3a4f28-633c-440c-8631-905710e9302d");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
IRestResponse response5 = client.Execute(request);
Console.WriteLine(response.Content);
响应:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 500 </title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /rest/ids. Reason:
<pre> Server Error</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>
检查后。 添加 header request.AddHeader("Accept", "*/*")
已解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.