Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sendgrid/csharp-http-client
Twilio SendGrid's C# HTTP Client for calling APIs
https://github.com/sendgrid/csharp-http-client
fluent-interface http-client rest-client
Last synced: 2 months ago
JSON representation
Twilio SendGrid's C# HTTP Client for calling APIs
- Host: GitHub
- URL: https://github.com/sendgrid/csharp-http-client
- Owner: sendgrid
- License: mit
- Created: 2016-03-03T18:57:30.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2023-04-10T00:22:38.000Z (almost 2 years ago)
- Last Synced: 2024-08-03T03:04:24.841Z (5 months ago)
- Topics: fluent-interface, http-client, rest-client
- Language: C#
- Homepage: https://sendgrid.com
- Size: 452 KB
- Stars: 24
- Watchers: 164
- Forks: 43
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- Awesome-Nuget-Packages - **SendGrid.CSharp.HTTP.Client**
README
![SendGrid Logo](twilio_sendgrid_logo.png)
[![Test and Deploy](https://github.com/sendgrid/csharp-http-client/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/sendgrid/csharp-http-client/actions/workflows/test-and-deploy.yml)
[![NuGet](https://img.shields.io/nuget/v/SendGrid.CSharp.Http.Client.svg)](https://www.nuget.org/packages/SendGrid.CSharp.HTTP.Client)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/csharp-http-client.svg)](https://github.com/sendgrid/csharp-http-client/graphs/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](https://github.com/sendgrid/sendgrid-csharp).
# Table of Contents
* [Announcements](#announcements)
* [Installation](#installation)
* [Quick Start](#quick-start)
* [Library Usage Documentation](USAGE.md)
* [Use Cases](#use-cases)
* [How to Contribute](#contribute)
* [Thanks](#thanks)
* [About](#about)
* [Support](#support)
* [License](#license)
# Announcements
All updates to this project are documented in our [CHANGELOG](CHANGELOG.md).## 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](Example) folder.Add the following namespace to use the library:
```csharp
using SendGrid.CSharp.HTTP.Client;
```Here is a quick example:
`GET /your/api/{param}/call`
```csharp
using SendGrid.CSharp.HTTP.Client;
globalRequestHeaders.Add("Authorization", "Bearer XXXXXXX");
dynamic client = new Client(host: baseUrl, requestHeaders: globalRequestHeaders);
var response = await 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.
```csharp
using SendGrid.CSharp.HTTP.Client;
using Newtonsoft.Json;
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}";
Object json = JsonConvert.DeserializeObject(requestBody);
var response = await client.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());
```You can find a selection of use cases for this library in our [Use Cases](/UseCases/README.md) directory.
We encourage contribution to our projects, please see our [CONTRIBUTING](CONTRIBUTING.md) guide for details.
Quick links:
- [Feature Request](CONTRIBUTING.md#feature-request)
- [Bug Reports](CONTRIBUTING.md#submit-a-bug-report)
- [Improvements to the Codebase](CONTRIBUTING.md#improvements-to-the-codebase)We were inspired by the work done on [birdy](https://github.com/inueni/birdy) and [universalclient](https://github.com/dgreisen/universalclient).
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](https://support.sendgrid.com).
# License
[The MIT License (MIT)](LICENSE)