每当我在Http请求中添加一个HTTP主体时,我都会得到一个401响应代码。同样的请求在postman中运行得非常好。
var client = new RestClient("http://10.10.2.10:9000/haproxy_stats");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic QURNSU46UGFzc3dvcmQtMTIzNA==");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("s", "server2");
request.AddParameter("action", "ready");
request.AddParameter("b", "#2");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
1条答案
按热度按时间yc0p9oo01#
从postman获取代码片段并复制cookie标题行。希望它对您有用。