簡體   English   中英

找不到 IRestResponse

[英]IRestResponse could not be found

我通過 nuget 加載了 restsharp 107.1.2 目標框架是 .net 6.0。 以下代碼聲稱缺少 IRestResponse 參考,盡管我覺得我非常接近 RestSharp 文檔。 我錯過了什么?

using RestSharp;
using RestSharp.Authenticators;
using System.Text;



static void Main()
{

    
    String url = "https://www.invoicecloud.com/api/v1/biller/status/";

    //Set up the RestClient
    var client = new RestClient(url);

    //Store the generated API from the biller portal
    String GeneratedAPIKey = "SomeKey=";

    //Convert genrated API key to Base64
    String encodedAPIKey = encoding(GeneratedAPIKey);

    //HTTPBasicAuthentication will take a username and a password
    //Here we use your API key as the username and leave the password with ""
    client.Authenticator =  new HttpBasicAuthenticator(encodedAPIKey, "");

  


    //Get the request
    var request = new RestRequest("resource", Method.Get);

    //Get the response

   // var response = client.ExecuteGetAsync(request);

    IRestResponse reponse = client.Execute(request);

根據文檔( https://restsharp.dev/v107/#restsharp-v107 )...

The IRestResponse interface is deprecated. You get an instance of RestResponse or RestResponse<T> in return.

https://restsharp.dev/v107/#deprecated-interfaces

同樣,根據文檔...

var client = new RestClient("https://api.myorg.com");

var request = new RestRequest()
    .AddQueryParameter("foo", "bar")
    .AddJsonBody(someObject);

var response = await client.PostAsync<MyResponse>(request, cancellationToken);

... 舉個例子。

暫無
暫無

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

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