Skip to content

Repository files navigation

SendGrid Logo

Test and DeployNuGetMIT licensedTwitter FollowGitHub contributors

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

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

Table of Contents

Announcements

All updates to this project are documented in our CHANGELOG.

Installation

Prerequisites

  • .NET Framework 4.5+

Install Package

To use CSharp.HTTP.Client in your C# project, you can either download the Twilio 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:

usingSendGrid.CSharp.HTTP.Client;

Quick Start

Here is a quick example:

GET /your/api/{param}/call

usingSendGrid.CSharp.HTTP.Client;globalRequestHeaders.Add("Authorization","Bearer XXXXXXX");dynamicclient=newClient(host:baseUrl,requestHeaders:globalRequestHeaders);varresponse=awaitclient.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.

usingSendGrid.CSharp.HTTP.Client;usingNewtonsoft.Json;globalRequestHeaders.Add("Authorization","Bearer XXXXXXX");dynamicclient=newClient(host:baseUrl,requestHeaders:globalRequestHeaders);stringqueryParams=@"{'Hello': 0, 'World': 1}";requestHeaders.Add("X-Test","test");stringrequestBody=@"{'some': 1, 'awesome': 2, 'data': 3}";Objectjson=JsonConvert.DeserializeObject<Object>(requestBody);varresponse=awaitclient.your.api._(param).call.post(requestBody:json.ToString(),queryParams:queryParams,requestHeaders:requestHeaders)
Console.WriteLine(response.StatusCode);Console.WriteLine(response.Body.ReadAsStringAsync().Result);Console.WriteLine(response.Headers.ToString());

Use Cases

You can find a selection of use cases for this library in our Use Cases directory.

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 maintained and funded by Twilio SendGrid, Inc. The names and logos for csharp-http-client are trademarks of Twilio SendGrid, Inc.

If you need help using SendGrid, please check the Twilio SendGrid Support Help Center.

License

The MIT License (MIT)

About

Twilio SendGrid's C# HTTP Client for calling APIs

Topics

Resources

Code of conduct

Contributing

Stars

26 stars

Watchers

151 watching

Forks

Releases

Packages

Used by

Contributors

Languages