簡體   English   中英

RestSharp 無法連接到遠程服務器

[英]RestSharp Unable to connect to remote server

我試圖在控制台應用程序中使用 RestSharp,連接到 api 並獲取 cookie,但在響應中,我不斷收到“無法連接到遠程服務器”。

        var client = new RestClient("http://finans-dk.pronestor.com/Api.mvc/v1/Authenticate");
        client.Authenticator = new SimpleAuthenticator("login", "????", "password", "????");

        var request = new RestRequest("resource", Method.GET);
        IRestResponse response = client.Execute(request);

我基本上希望 RestSharp 調用以下內容:

finans-dk.pronestor.com/Api.mvc/v1/Authenticate?login=???&password=???

這在郵遞員中對我有效,但在restsharp中無效。 我已經使用http://ip.jsontest.com進行了測試,以測試我是否可以連接到任何外部 api,這有效並恢復了我的 ip。 有任何想法嗎???

將您的代碼更改為:

var client = new RestClient("https://finans-dk.pronestor.com/Api.mvc/v1/");
client.Authenticator = new SimpleAuthenticator("login", "????", "password", "????");

var request = new RestRequest("Authenticate", Method.GET);
IRestResponse response = client.Execute(request);

您沒有正確查看鏈接到的文檔。 在其示例中,URL 是:

http://example.com/resource?username=foo&password=bar

注意resource出現的位置。 您的 URL 在該位置顯示為Authenticate

暫無
暫無

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

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