Skip to content

InlineAsm/RestSharp

This branch is 809 commits behind restsharp/RestSharp:dev.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e6dea9a · Sep 18, 2018
Sep 3, 2017
Oct 16, 2017
Sep 18, 2018
Sep 18, 2018
Sep 18, 2018
Sep 7, 2013
Oct 22, 2017
Jan 14, 2018
Nov 16, 2009
Dec 2, 2017
Jun 10, 2018
Nov 7, 2014
Nov 19, 2017
Sep 18, 2018
Oct 5, 2015
Sep 18, 2018
Oct 16, 2017

Repository files navigation

RestSharp - Simple .NET REST Client

Build status

Join the chat at https://gitter.im/RestSharp/RestSharp

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.

Features

  • 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
  • GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE, COPY 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
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
await client.ExecuteAsync(request);

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

// abort the request on demand
asyncHandle.Abort();

About

Simple REST and HTTP API Client for .NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%