Skip to content
Simple REST and HTTP API Client for .NET
C# Batchfile
Find file
Latest commit e7c65df Apr 26, 2016 @hallem hallem Merge pull request #768 from MatthewKing/master
Fix RestRequest.RequestFormat documentation.
Failed to load latest commit information.
.nuget prepped a new version and fixed the build bat for monotouch and remov… Aug 26, 2015
RestSharp.Android Added nuget targets for windows phone 8 and 8.1, monotouch10, monoand… Aug 18, 2015
RestSharp.Build Added nuget targets for windows phone 8 and 8.1, monotouch10, monoand… Aug 19, 2015
RestSharp.IntegrationTests Merge pull request #825 from tecmobo/fix-810 Apr 26, 2016
RestSharp.MonoTouch Added nuget targets for windows phone 8 and 8.1, monotouch10, monoand… Aug 19, 2015
RestSharp.Net4.Client Added nuget targets for windows phone 8 and 8.1, monotouch10, monoand… Aug 19, 2015
RestSharp.Net4 Added nuget targets for windows phone 8 and 8.1, monotouch10, monoand… Aug 19, 2015
RestSharp.Net45 Added NET45 compile constants Feb 4, 2016
RestSharp.Net451 Added NET45 compile constants Feb 4, 2016
RestSharp.Net452 Added NET45 compile constants Feb 4, 2016
RestSharp.Net46 Added NET45 compile constants Feb 4, 2016
RestSharp.Silverlight Added nuget targets for windows phone 8 and 8.1, monotouch10, monoand… Aug 19, 2015
RestSharp.Tests Merge pull request #748 from mwereda/master Apr 26, 2016
RestSharp.UWP Added Restsharp.UWP project Nov 12, 2015
RestSharp.WindowsPhone.8.0 Added nuget targets for windows phone 8 and 8.1, monotouch10, monoand… Aug 19, 2015
RestSharp.WindowsPhone.8.1 Added nuget targets for windows phone 8 and 8.1, monotouch10, monoand… Aug 19, 2015
RestSharp.iOS Added nuget targets for windows phone 8 and 8.1, monotouch10, monoand… Aug 19, 2015
RestSharp Merge pull request #768 from MatthewKing/master Apr 26, 2016
Tools added this prefix to the compression library (missed before) and clea… Aug 15, 2015
.gitattributes Add gitattributes and fix line-endings Sep 6, 2013
.gitignore Add integration test for OAuth1 authentication against Twitter API Dec 8, 2014
CONTRIBUTING.markdown Converted tabs to spaces and corrected an error; Oct 25, 2014
LICENSE.txt Added license Nov 16, 2009
README.markdown It supports PATCH Apr 20, 2016
RestSharp.sln Added Restsharp.UWP project Nov 12, 2015
RestSharp.snk Added capability for strong naming on the core library. This was done… Nov 6, 2014
appveyor.yml updated appveyor.yml Aug 19, 2015
build.bat prepped a new version and fixed the build bat for monotouch and remov… Aug 26, 2015
readme.txt Added nuget targets for windows phone 8 and 8.1, monotouch10, monoand… Aug 19, 2015
releasenotes.markdown updated release notes Aug 18, 2015
restsharp.nuspec adding NuSpecUpdateTask to RestSharp.csproj Aug 27, 2013

README.markdown

RestSharp - Simple .NET REST Client Build status

RestSharp is in need of more maintainers. Specifically ones who have more experience with PCL and UWP. If you're interested, please open an issue at RestSharp Maintainers.

Official Site/Blog - @RestSharp

License: Apache License 2.0

Features

  • Supports .NET 3.5+, Silverlight 5, Windows Phone 8, Mono, MonoTouch, Mono for Android
  • Easy installation using NuGet for most .NET flavors
  • Supports strong naming using NuGet for most .NET flavors
  • 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
  • GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE supported
  • 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
  • T4 Helper to generate C# classes from an XML document
var client = new RestClient("http://example.com");
// client.Authenticator = new HttpBasicAuthenticator(username, password);

var request = new RestRequest("resource/{id}", Method.POST);
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
request.AddObject(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
IRestResponse response = client.Execute(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();
IRestResponse<Person> response2 = client.Execute<Person>(request);
var name = response2.Data.Name;

// or download and save file to disk
client.DownloadData(request).SaveAs(path);

// easy async support
client.ExecuteAsync(request, response => {
    Console.WriteLine(response.Content);
});

// async with deserialization
var asyncHandle = client.ExecuteAsync<Person>(request, response => {
    Console.WriteLine(response.Data.Name);
});

// abort the request on demand
asyncHandle.Abort();
Something went wrong with that request. Please try again.