Questions tagged [restsharp]

RestSharp is a simple to use REST client library for .NET

RestSharp takes the pain out of calling REST services from .NET. This library takes care of the quirks in .NET's HTTP classes, handles deserialization cleanly, simplifies making asynchronous calls, and just makes it really easy to implement calls to REST services from inside your application.

RestSharp comes with a built-in JSON serializer. The default serializer has been compatible with the Json.NET project but this compatibility has been given up since release 100.3.

Installation Installing RestSharp can most easily be done using its NuGet package:

Install-Package RestSharp

Resources

2486 questions
0
votes
2 answers

Deserialize RESTSharp Response Ignoring Headers

I am looking to deserialize the data returned from a REST API. I am struggling to get the data to map to my object. It seems like I am probably looking at the entire JSON response and not isolating in on the 'data' portion of the response. My…
Zoop
  • 872
  • 3
  • 11
  • 24
0
votes
1 answer

RestRequest no longer contains AddJsonBody

I have been using restsharp to make this simple request to a webservice: string sParmDb = Newtonsoft.Json.JsonConvert.SerializeObject(parmsDb);// parmsDb is some object too large to be passed as a query parameter sParmDb =…
0
votes
4 answers

Deserialize a JsonResult from C#

I access a REST API with this code : public async Task NetExplorerAPI(string AdresseAPI, object Requete, RestSharp.Method Methode) { var client = new RestClient(AdresseAPI); var request = new RestRequest(); request.Method…
0
votes
1 answer

How to use WebProxy with RestSharp?

I would like to know how to use WebProxy with RestSharp. I am using version 108.0.1 and the code given below returns 407 when running locally from my workstation, which should use my credentials. var client = new…
Anand
  • 1,387
  • 2
  • 26
  • 48
0
votes
1 answer

Restsharp delay prior to call (15 sec) - postman instant

I have the following code in a C# WPF app. This has been working perfectly in testing for a month: try { string zServerName = "http://" + dispenseDetails.dipenseServerCompName + ":8800/Api/"; var options = new…
GAngel
  • 1
  • 2
0
votes
0 answers

How to form Restsharp Get Request with Oauth2 and display it via console

I am wondering if anyone knows how to do make a Get request with Oauth2 and display it on the console? Here is my code so far: static void Main(string[] args) { string url = "https://api.test"; var client = new…
nsempf
  • 1
0
votes
0 answers

Restsharp giving cached API responses even when the API server is turned off

I have a working NodeJS API being called from a WPF C# app. It has been running for 12 months with no issues, using RestSharp from my C# end. My server went down today (weird spike) and since then about 50% of my calls are responding with cached…
GAngel
  • 1
  • 2
0
votes
2 answers

RestSharp returns no response

I have an ASP.NET Core 6 project using RestSharp (v107.3.0). Sometimes, I don't how the frequency, luckily it's not often, the library returns a null response and a 0 response status code whatever the API sends. Here is my code : private async…
Rémy
  • 736
  • 1
  • 5
  • 19
0
votes
1 answer

What is the idiomatic way to make a get request using RestSharp?

I'm trying to make a GET request to a REST api which returns a JSON. This is what I have right now: RestClient client = new RestClient(BASE_URL); var request = new RestRequest(CONTROLLER_PATH); var response = await…
0
votes
0 answers

How to pass request body with RestSharp array

Please tell me how to pass an array in the request body using RestSharp. It is necessary to transfer such a body: { "object extract": { "extractType": "Ownership", "objects": [ { "cadastralNumber":…
0
votes
1 answer

C# Build JSON payload - List in List

I have huge problems with building an JSON-payload. Hopefully, someone can give me a push in the right direction. With PostMan it's easy to CRUD-Articles, with C# i'm struggling here. The UomUnitPrices makes me headache. First of all, i need to do…
0
votes
1 answer

RestSharp POST problems

so basically i started learning http request with restsharp and to be honest there is a total confusion. So i managed to log into my reddit account, catch upvote post request and i tried to post the method and it actually worked on the active…
0
votes
0 answers

How do I call mixed code (async and sync)?

I'm working on an ASP.NET MVC application which has an external reference like this: public class AuthorizationApi : BaseApi { public AuthorizationApi() { } public Configuration LogIn(string username, string password) { …
mb14
  • 460
  • 4
  • 15
0
votes
1 answer

Content-Type header property value quoting doesn't work with third-party server

Is it correct to quote the boundary property value of Content-Type header? I have sent an http-request with two files to a third-party server and get the following response: Boundary '--"38b14895-fd44-4acc-8287-9f0378691da2"' not found in message…
exGens
  • 1
  • 1
0
votes
1 answer

Resharp DI and DNS resolution

I'm upgrading to version 107 restsharp and i'm wondering if both these options below are ok ways of doing dependency injection in dotnet with restsharp. The documents say don't create a new restsharp for every request (connection pool exhaustion…
Paul McTigue
  • 221
  • 2
  • 7