簡體   English   中英

請求來自 Postman 但不是來自 c# 代碼

[英]Request works from Postman but not from c# code

每當我將 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);

從 postman 獲取代碼片段並復制 cookie header 行。我希望它對你有用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM