Ad
IRestResponse Could Not Be Found
I have restsharp 107.1.2 loaded via nuget target framework is .net 6.0. The following code claims that IRestResponse reference is missing, though I feel like I'm following pretty close to the RestSharp documentation. What am I missing?
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);
Ad
Answer
As per the documentation (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
Again, according to the documentation ...
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);
... as an example.
Ad
source: stackoverflow.com
Related Questions
- → How to Fire Resize event after all images resize
- → JavaScript in MVC 5 not being read?
- → URL routing requires /Home/Page?page=1 instead of /Home/Page/1
- → Getting right encoding from HTTPContext
- → How to create a site map using DNN and C#
- → I want integrate shopify into my mvc 4 c# application
- → Bootstrap Nav Collapse via Data Attributes Not Working
- → Shopify api updating variants returned error
- → Get last n quarters in JavaScript
- → ASP.NET C# SEO for each product on detail page on my ECOMMERCE site
- → SEO Meta Tags From Behind Code - C#
- → onchange display GridView record if exist from database using Javascript
- → How to implement search with two terms for a collection?
Ad