Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

riskfirst/riskfirst.restclient

Open more actions menu

Repository files navigation

Riskfirst.RestClient

CI Build

A fluent inteface used for making RESTful requests.

Getting started

Install the package from Nuget.org

PM> Install-Package RiskFirst.RestClient

Make a simple RESTful GET request

var myServiceUri = new Uri("https://myservice.com");
var response = myServiceUri.AsRestRequest()
                        .GetAsync()
                        .ReceiveAsync();

The above will return an instance of HttpResponseMessage which can be used to read the status code, or any other property. You can also receive a JSON response for your custom object.

var myServiceUri = new Uri("https://myservice.com");
var response = myServiceUri.AsRestRequest()
                        .GetAsync()
                        .ReceiveJsonAsync<MyClass>();

The above will return an instance of MyClass deserialized from the response message, or throw a RestResponseException on a non-success response.

A note on HttpClient

This library uses a static instance of HttpClient for all requests, as per the advice in this advice however clients of this library are free to provide their own instance of HttpClient if they wish. You should be aware of this post regarding the use of a static HttpClient

This is an optional parameters on all request methods:

var myServiceUri = new Uri("https://myservice.com");
var response = myServiceUri.AsRestRequest()
                        .GetAsync(myHttpClientInstance)
                        .ReceiveJsonAsync<MyClass>();

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 7

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.