Skip to content
Simple REST and HTTP API Client for .NET
Branch: master
Clone or download
Latest commit 44333cc Feb 28, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Created Issue and PR templates Sep 3, 2017
.nuget Added GitVersion task Oct 16, 2017
RestSharp.IntegrationTests Adding a test for custom JSON serializer and AddJsonBody Feb 19, 2019
RestSharp.Tests Issue 1273 Feb 13, 2019
.gitignore Update Jan 14, 2018
LICENSE.txt Added license Nov 16, 2009 Update Jan 26, 2019
RestSharp.sln Adding dotnet restore Jun 10, 2018
RestSharp.snk Added capability for strong naming on the core library. This was done… Nov 7, 2014
appveyor.yml Some fixes in the build script Nov 19, 2017
build.bat Adding documentation tag and bumping the version Sep 18, 2018
readme.txt Update readme.txt Oct 5, 2015

RestSharp - Simple .NET REST Client

Build status

Join the chat at

Official Site - @RestSharp - Google Group

License: Apache License 2.0

Note on RestSharp.Signed

The RestSharp package is now signed so there is no need to install RestSharp.Signed, which is obsolete from v160.0.0.

Note on JSON serialization

Some time ago, we have decided to get rid of the reference to Newtonsoft.Json package. The intentions were good, we thought that the SimpleJson library would be a good replacement that can be embedded to the library itself, so we don't need to have any external references.

However, as many good intentions, that change created more issues than it solved. The number of issues on GitHub that are related to JSON (de)serialization is growing and SimpleJson is long abandoned. We faced a choice to start maintaining SimpleJson ourselves or use something else.

Since as per today almost every .NET project has a direct or indirect reference to Newtonsoft.Json, we decided to bring it back as a dependency and get rid of SimpleJson. This will be done in RestSharp v107, the next major version.

To prepare for this change, we made quite a few changes in how serialization works in RestSharp. Before, objects were serialized when added to the RestRequest by using one of the AddBody methods. That made it impossible to assign a custom serializer on the client level, so it should have been done for each request. In v106.6 body parameter is serialized just before executing the request. Delaying the serialization allowed us to add the client-level serializer.

It is still possible to assign custom (de)serializer per request, as before. In addition to that, you can use the new method IRestClient.UseSerializer(IRestSerializer restSerializer). The IRestSerializer interface has methods for serialization and deserialization. Default serializers are the same as before.

From v106.6.2 you can use Newtonsoft.Json for the RestClient by using code from this snippet.

In addition to that, you can change the default XML serialization to use the System.Xml serializer, also known as DotNetXmlSerializer and DotNetXmlDeserializer. In v106.6.2, you can simply write:



  • Assemblies for .NET 4.5.2 and .NET Standard 2.0
  • Easy installation using NuGet for most .NET flavors (signed)
  • Automatic XML and JSON deserialization
  • Supports custom serialization and deserialization via ISerializer and IDeserializer
  • Fuzzy element name matching ('product_id' in XML/JSON will match C# property named 'ProductId')
  • Automatic detection of type of content returned
  • Other non-standard HTTP methods also supported
  • OAuth 1, OAuth 2, Basic, NTLM and Parameter-based Authenticators included
  • Supports custom authentication schemes via IAuthenticator
  • Multi-part form/file uploads
var client = new RestClient("");
// client.Authenticator = new HttpBasicAuthenticator(username, password);

var request = new RestRequest("resource/{id}");
request.AddParameter("name", "value"); // adds to POST or URL querystring based on Method
request.AddUrlSegment("id", "123"); // replaces matching token in request.Resource

// add parameters for all properties on an object

// or just whitelisted properties
request.AddObject(object, "PersonId", "Name", ...);

// easily add HTTP Headers
request.AddHeader("header", "value");

// add files to upload (works with compatible verbs)
request.AddFile("file", path);

// execute the request
var response = client.Post(request);
var content = response.Content; // raw content as string

// or automatically deserialize result
// return content type is sniffed but can be explicitly set via RestClient.AddHandler();
var response2 = client.Post<Person>(request);
var name = response2.Data.Name;

// or download and save file to disk

// easy async support
await client.ExecuteAsync(request);

// async with deserialization
var asyncHandle = client.PostAsync<Person>(request, response => {

// abort the request on demand
You can’t perform that action at this time.