Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple REST and HTTP API Client for .NET
C# Shell
Failed to load latest commit information.
.nuget updated the nuget package
RestSharp.Android Using file linking for ResponseStatusExtensions.cs instead of copies
RestSharp.Build Migrated support for the changes to the signed projects as well
RestSharp.IntegrationTests Added unit test for AlwaysMultipartFormData_WithParameter_ExecuteTask…
RestSharp.MonoTouch Using file linking for ResponseStatusExtensions.cs instead of copies
RestSharp.Net4 Migrated support for the changes to the signed projects as well
RestSharp.Net45 added targeting for .net 4.5.1 and 4.5.2 framework editions
RestSharp.Net451 added targeting for .net 4.5.1 and 4.5.2 framework editions
RestSharp.Net452 added targeting for .net 4.5.1 and 4.5.2 framework editions
RestSharp.Silverlight Cleared up build error and added if/def's to the response status exte…
RestSharp.Tests added invariant culture to exponential notation test; closes #671
RestSharp.WindowsPhone added WP8 compiler symbol which incorporates awaitable async methods …
RestSharp.iOS Using file linking for ResponseStatusExtensions.cs instead of copies
RestSharp Merge pull request #683 from issafram/Issue672
Tools updated the nuget package
.gitattributes Add gitattributes and fix line-endings
.gitignore Add integration test for OAuth1 authentication against Twitter API
CONTRIBUTING.markdown Converted tabs to spaces and corrected an error;
LICENSE.txt Added license
README.markdown Updated Windows Phone version number for support
RestSharp.Compact.sln Added VS2008 project for CF.
RestSharp.Mono.sln Add gitattributes and fix line-endings
RestSharp.Signed.sln added targeting for .net 4.5.1 and 4.5.2 framework editions
RestSharp.Xamarin.sln Added and updated the Xamarin projects:
RestSharp.sln added targeting for .net 4.5.1 and 4.5.2 framework editions
RestSharp.snk Added capability for strong naming on the core library. This was done…
build.bat added targeting for .net 4.5.1 and 4.5.2 framework editions
package.cmd added targeting for .net 4.5.1 and 4.5.2 framework editions
packageAll.cmd Updated the build DLL in the .nuget dir and added the copy for the si…
packageSigned.cmd added targeting for .net 4.5.1 and 4.5.2 framework editions
readme.txt Update readme.txt
releasenotes.markdown updated the nuget package
restsharp.nuspec adding NuSpecUpdateTask to RestSharp.csproj

README.markdown

RestSharp - Simple .NET REST Client Build status

Official Site/Blog - @RestSharp

License: Apache License 2.0

Features

  • Supports .NET 3.5+, Silverlight 4, 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, 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.