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
16
votes
3 answers

RestSharp: How to skip serializing null values to JSON?

RestSharp's built-in JSON serializer serializes all of an object's properties, even if they're null or otherwise the default value. How can I make it skip these properties?
Bryan
  • 1,431
  • 1
  • 17
  • 22
14
votes
4 answers

Why is my Initial call in RestSharp really slow? but others after are very fast

I am making calls to a WEB API using RESTSHARP and they work fine. However, the Initial call to the API (regardless of what call it is) can sometimes take up to 10 seconds to get a response. Every other call after that is really quick. Does anyone…
Neil Hobson
  • 515
  • 1
  • 7
  • 14
14
votes
1 answer

Persistent HTTP Connection with RestSharp

I am using RestSharp to consume a REST web service and will be making a large volume of calls in a short time period. The documentation for the API strongly recommends the use of persistent HTTP connections to do this, however I am struggling to get…
Adam Cobb
  • 894
  • 4
  • 14
  • 33
14
votes
1 answer

HttpStatus and DownloadData

I'm trying to download a file (an image) with RestSharp using the DownloadData method var client = new RestClient(baseUrl); var request = new RestRequest("GetImage", Method.GET); var response = client.DownloadData(request); This works fine, but…
Michael Skarum
  • 2,448
  • 3
  • 18
  • 20
13
votes
1 answer

Request timeout from ASP.NET Core app on IIS

I make a web request to a third-party api from my ASP.NET Core application. When app is running alone itself, request succeeds. When app is running in IIS on the same server, request timeouts. Request is made from a Hangfire recurring job to…
Mikhail Zhuravlev
  • 969
  • 2
  • 10
  • 22
13
votes
1 answer

RestSharp v. WebClient?

I'm building a Windows Phone 7 Silverlight app. Is there any reason to use RestSharp instead of WebClient? I've looked around on the RestSharp site, but it's not immediately obvious what the benefits are.
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
13
votes
4 answers

Maintaining a single instance to a RestSharp client

Along similar lines to this question, is it okay to instantiate a client and hold on to it, or do I need to create a new instance for every call (or batch of calls)?
gregsdennis
  • 7,218
  • 3
  • 38
  • 71
13
votes
2 answers

RestSharp JSON Array deserialization

I launch this RestSharp query in JSON format: var response = restClient.Execute(request); The response I get contains this data [ { "Columns": [ {"Name":"CameraGuid","Type":"Guid"}, …
BriocheBro
  • 165
  • 1
  • 1
  • 5
13
votes
3 answers

The '`' character and RestSharp request body during sending the list

I am trying to Post request with my entities using RestSharp. But I receive an error: "System.Xml.XmlException : The '`' character, hexadecimal value 0x60, cannot be included in a name." I am placing the list in the body of the query. var strList…
Alex Blokha
  • 1,141
  • 2
  • 17
  • 30
13
votes
1 answer

RestSharp client returns all properties as null when deserializing JSON response

I'm trying to do a very simple example of using RestSharp's Execute method of querying a rest endpoint and serializing to a POCO. However, everything I try results in a response.Data object that has all properties with a NULL value. Here is the JSON…
smercer
  • 916
  • 1
  • 6
  • 15
12
votes
2 answers

RestSharp - Token authentication

I'm trying to send a GET request with a token authentication, but i get an unauthorized response. If i send the same request on Postman, it works. Here's my code : string url = string.Format("{0}batchs", MyUrl); RestClient client = new…
Kévin Buzit
  • 141
  • 1
  • 1
  • 4
12
votes
3 answers

RestSharp showing Error of Cannot create an instance of an interface have to manually deserialize

I have RestSharp (which is like HttpClient) call and return data from a Web Api method I'm getting this error {"Cannot create an instance of an interface."} My code looks like this: public List GetInterests() { var request = new…
Timothy Fisher
  • 185
  • 1
  • 11
12
votes
1 answer

RestSharp error when shared as a dependency and different publicKeyTokens

Using APIs from Docusign, Twilio and Auth0. All 3 have RestSharp.dll as a dependency. If I use the RestSharp.dll included with the Docusign package, Docusign works well but Auth0 and Twillio give errors: Could not load file or assembly 'RestSharp,…
Ben B
  • 335
  • 1
  • 5
  • 18
12
votes
3 answers

Serializing an object with restsharp and passing it to WebApi not serializing list

I have a a view model that looks like. public class StoreItemViewModel { public Guid ItemId { get; set; } public List StoreIds { get; set; } [Required] public string Description { get; set; } //[Required] …
Diver Dan
  • 9,953
  • 22
  • 95
  • 166
12
votes
2 answers

How to parse JSON using RestSharp?

var client = new RestClient("http://10.0.2.2:50670/api"); var request = new RestRequest("Inventory", Method.GET); request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; }; // execute the request to return a list of…
Josh
  • 1,019
  • 3
  • 17
  • 32