我有restsharp 107.1.2通过nuget目标框架加载是.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);
发布于 2022-01-31 04:22:12
根据文档(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);
..。举个例子。
https://stackoverflow.com/questions/70921065
复制相似问题