REST client for .NET
Switch branches/tags
Nothing to show
Pull request Compare This branch is 25 commits ahead, 1098 commits behind restsharp:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
References
RestSharp.IntegrationTests
RestSharp.MonoTouch
RestSharp.Silverlight
RestSharp.Tests
RestSharp.WindowsPhone
RestSharp
.gitignore
LICENSE.txt
README.markdown
RestSharp.sln
RestSharp2008.sln

README.markdown

RestSharp - .NET REST Client That (Hopefully) Doesn't Suck

http://restsharp.org - @RestSharp

License: Apache License 2.0

Key Features

  • Automatic XML and JSON deserialization
  • Fuzzy name matching ('product_id' in XML/JSON will match property named 'ProductId')
  • Automatic detection of type of content returned
  • GET, POST, PUT, HEAD, OPTIONS, DELETE supported
  • Basic, NTLM and Parameter-based Authenticators included
  • Supports custom authentication schemes
  • Multi-part form/file uploads
  • T4 Helper to generate C# classes from an XML document

Basic Usage

var client = new RestClient();
client.BaseUrl = "http://example.com";
// client.Authenticator = new BasicAuthenticator(username, password);

var request = new RestRequest(); // GET by default
// request.Method = Method.GET | Method.POST | Method.PUT | Method.DELETE | Method.HEAD | Method.OPTIONS
request.Resource = "resource";
request.AddParameter("name", "value");

// 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.AddParameter("header", "value", ParameterType.HttpHeader);

// supports XML/JSON request bodies
request.RequestFormat = RequestFormat.Xml;
request.AddBody(object);

// add files (only works with compatible verbs)
request.AddFile(path);
    
// get raw response
RestResponse response = client.Execute(request);
// response.Content : string representation of response

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

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

// shortcuts for parsing xml/feeds
client.ExecuteAsXDocument(request);
client.ExecuteAsXmlDocument(request);
client.ExecuteAsSyndicationFeed(request);