GithubHelp home page GithubHelp logo

sarvex / restsharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from restsharp/restsharp

0.0 2.0 0.0 34.76 MB

Simple REST and HTTP API Client for .NET

Home Page: http://restsharp.org

License: Apache License 2.0

C# 98.72% Shell 1.28%

restsharp's Introduction

RestSharp - Simple .NET REST Client Build status

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();

restsharp's People

Contributors

ayoung avatar brettryan avatar davidgrupp avatar devatwork avatar dkarzon avatar eamonhetherton avatar erikschierboom avatar friism avatar haacked avatar hallem avatar issafram avatar johnsheehan avatar jonfuller avatar jsclayton avatar lukebakken avatar mattleibow avatar mstum avatar naliath avatar nicstrong avatar pedrolamas avatar perlun avatar petejohanson avatar prabirshrestha avatar pseudomuto avatar rmblstrp avatar scidec avatar scottschluer avatar sgrassie avatar tathamoddie avatar zidad avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.