Skip to content

julianonunes/csharp-http-client

 
 

Repository files navigation

Travis Badge

Quickly and easily access any RESTful or RESTful-like API.

If you are looking for the SendGrid API client library, please see this repo.

Announcements

All updates to this project is documented in our CHANGELOG.

Installation

To use CSharp.HTTP.Client in your C# project, you can either download the SendGrid C# .NET libraries directly from our Github repository or, if you have the NuGet package manager installed, you can grab them automatically.

PM> Install-Package SendGrid.CSharp.Http.Client

Once you have the library properly referenced in your project, you can include calls to them in your code. For a sample implementation, check the Example folder.

Add the following namespace to use the library:

using SendGrid.CSharp.HTTP.Client;

Quick Start

Here is a quick example:

GET /your/api/{param}/call

using SendGrid.CSharp.HTTP.Client;
globalRequestHeaders.Add("Authorization", "Bearer XXXXXXX");
dynamic client = new Client(host: baseUrl, requestHeaders: globalRequestHeaders);
client.your.api._(param).call.get()
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
Console.WriteLine(response.Headers.ToString());

POST /your/api/{param}/call with headers, query parameters and a request body with versioning.

using SendGrid.CSharp.HTTP.Client;
globalRequestHeaders.Add("Authorization", "Bearer XXXXXXX");
dynamic client = new Client(host: baseUrl, requestHeaders: globalRequestHeaders);
string queryParams = "{'Hello': 0, 'World': 1}";
requestHeaders.Add("X-Test", "test");
string requestBody = "{'some': 1, 'awesome': 2, 'data': 3}";
var response = client.your.api._(param).call.post(requestBody: requestBody,
                                                  queryParams: queryParams,
                                                  requestHeaders: requestHeaders)
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
Console.WriteLine(response.Headers.ToString());

Usage

Roadmap

If you are intersted in the future direction of this project, please take a look at our milestones. We would love to hear your feedback.

How to Contribute

We encourage contribution to our projects, please see our CONTRIBUTING guide for details.

Quick links:

Thanks

We were inspired by the work done on birdy and universalclient.

About

csharp-http-client is guided and supported by the SendGrid Developer Experience Team.

csharp-http-client is maintained and funded by SendGrid, Inc. The names and logos for csharp-http-client are trademarks of SendGrid, Inc.

![SendGrid Logo] (https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)

About

HTTP client for RESTful APIs, simplified for C#

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%