Skip to content
This repository

Simple REST and HTTP API Client for .NET

Merge pull request #471 from ryno1234/master

Added support for JsonArray and JsonObject deserialization when target type is specified as System.Object
latest commit 70be25dae0
Phil Haack Haacked authored
Octocat-spinner-32 .nuget Moving build task into separate project August 27, 2013
Octocat-spinner-32 RestSharp.Build Treat warnings as errors September 10, 2013
Octocat-spinner-32 RestSharp.IntegrationTests Fixed bug that caused the async RestClient callbacks to never get cal… March 15, 2014
Octocat-spinner-32 RestSharp.MonoDroid fix typo December 22, 2013
Octocat-spinner-32 RestSharp.MonoTouch fix typo December 22, 2013
Octocat-spinner-32 RestSharp.Net4 fix typo December 22, 2013
Octocat-spinner-32 RestSharp.Silverlight Treat warnings as errors September 10, 2013
Octocat-spinner-32 RestSharp.Tests JsonDeserializer now can deserialize objects JsonArray and JsonObject… March 20, 2014
Octocat-spinner-32 RestSharp.WindowsPhone.Mango Add gitattributes and fix line-endings September 06, 2013
Octocat-spinner-32 RestSharp.WindowsPhone Treat warnings as errors September 10, 2013
Octocat-spinner-32 RestSharp.WindowsPhone8 updated to include the new async method December 29, 2013
Octocat-spinner-32 RestSharp Merge pull request #471 from ryno1234/master March 20, 2014
Octocat-spinner-32 Tools Update NuGet September 18, 2013
Octocat-spinner-32 .gitattributes Add gitattributes and fix line-endings September 06, 2013
Octocat-spinner-32 .gitignore adding NuSpecUpdateTask to RestSharp.csproj August 27, 2013
Octocat-spinner-32 CONTRIBUTING.markdown Update CONTRIBUTING.markdown September 17, 2012
Octocat-spinner-32 LICENSE.txt Added license November 16, 2009
Octocat-spinner-32 README.markdown Updated README to include compact framework support. December 20, 2013
Octocat-spinner-32 RestSharp.Compact.sln Added VS2008 project for CF. December 20, 2013
Octocat-spinner-32 RestSharp.Mono.sln Add gitattributes and fix line-endings September 06, 2013
Octocat-spinner-32 RestSharp.sln Add Meta solution folder October 22, 2013
Octocat-spinner-32 build.bat Update build.bat September 10, 2013
Octocat-spinner-32 package.cmd Moving build task into separate project August 27, 2013
Octocat-spinner-32 readme.txt Update readme.txt November 18, 2013
Octocat-spinner-32 releasenotes.markdown Add release notes for 104.3.3 October 22, 2013
Octocat-spinner-32 restsharp.nuspec adding NuSpecUpdateTask to RestSharp.csproj August 27, 2013
README.markdown

RestSharp - Simple .NET REST Client

Official Site/Blog - @RestSharp

Please use the Google Group for feature requests and troubleshooting usage.

License: Apache License 2.0

Features

  • Supports .NET 3.5+, Silverlight 4, Windows Phone 7, Mono, MonoTouch, Mono for Android, Compact Framework 3.5
  • Easy installation 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(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.