Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rivantsov/arrest

.NET REST client
https://github.com/rivantsov/arrest

Last synced: about 2 months ago
JSON representation

.NET REST client

Awesome Lists containing this project

README

        

# ARREST - .NET REST client

**Arrest** is a client-side component for communicating with REST APIs and services. It is a wrapper around HttpClient with a number of convenient methods for automatically serializing/deserializing typed data objects.

Examples:
```c#
var client = new RestClient("http://www.bookstore.com");
var someBooks = await client.GetAsync>("api/books?take={0}", 10);
var theBook = client.Get("api/books/{0}", someBookId); //sync version
var myReview = new BookReview() { ... };
var myReviewBack = await client.PostAsync(myReview, "api/user/reviews");

```
The client handles HTTP status codes returned by the service (throws exceptions on BadRequest and Server errors).
Supports Json serialization. Supports sync and async operations.
See RestCallTests.cs class for examples of use.

You can pass additional request headers, and CancellationToken:
```c#
var someBook = await client.GetAsync("api/book/{0}", 123, ("X-Cor-Id", CorId), token);

```

You can get response headers and other information about response:
```c#
var contextBox = new ArgContextBox();
var someBook = await client.GetAsync("api/book/{0}", 123, ("X-Cor-Id", CorId), contextBox);
var respHeader = contextBox.GetResponseHeader("X-Cor-Id")?.FirstOrDefault();

var respMessage = contextBox.Response;

```

REST client supports automatic retries - just pass a RetryPolicy instance to the constructor