Skip to content

Commit 41ecf8f

Browse files
Adding documentation
1 parent 1410006 commit 41ecf8f

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,62 @@ myMessage.Text = "Hello World!";
159159
// should also be overwritten for link tracking purposes.
160160
myMessage.EnableClickTracking(true);
161161
```
162+
163+
#How to: Use the [Web API v3](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html)
164+
165+
Note: We have just begun to implement support for these endpoints and therefore only the following endpoints are currently supported. This functionality is located in the "SendGrid" project.
166+
167+
## API Keys ##
168+
169+
Please refer to [our documentation](https://sendgrid.com/docs/API_Reference/Web_API_v3/API_Keys/index.html) for further details.
170+
171+
List all API Keys belonging to the authenticated user [GET]
172+
173+
```csharp
174+
String apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
175+
var client = new SendGrid.Client(apiKey);
176+
// Leave off .Result for an asyncronous call
177+
HttpResponseMessage responseGet = client.ApiKeys.Get().Result; // Leave off .Result for an asyncronous call
178+
```
179+
180+
Generate a new API Key for the authenticated user [POST]
181+
182+
```csharp
183+
String apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
184+
var client = new SendGrid.Client(apiKey);
185+
var apiKeyName = "CSharpTestKey";
186+
// Leave off .Result for an asyncronous call
187+
HttpResponseMessage responsePost = client.ApiKeys.Post(apiKeyName).Result;
188+
```
189+
190+
Update the name of an existing API Key [PATCH]
191+
192+
```csharp
193+
String apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
194+
var client = new SendGrid.Client(apiKey);
195+
var apiKeyName = "CSharpTestKey";
196+
ver apiKeyId = "<API Key ID>";
197+
// Leave off .Result for an asyncronous call
198+
HttpResponseMessage responsePatch = client.ApiKeys.Patch(apiKeyId, apiKeyName).Result;
199+
```
200+
201+
Revoke an existing API Key [DELETE]
202+
203+
```csharp
204+
String apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
205+
var client = new SendGrid.Client(apiKey);
206+
ver apiKeyId = "<API Key ID>";
207+
// Leave off .Result for an asyncronous call
208+
HttpResponseMessage responseDelete = client.ApiKeys.Delete(apiKeyId).Result;
209+
```
210+
211+
#How to: Testing
212+
213+
* Load the solution (We have tested using the Visual Studio Community Edition)
214+
* In the Test Explorer, click "Run All". Tests for the Mail Send v2 endpoint are in the Tests project, while the tests for the v3 endpoints are in the UnitTests project. Selecting "Run All" from the Test Explorer will run the tests in both projects.
215+
216+
You can also test the code by building and running our "Example" project. It will run through the examples using an interactive console. You will need your API key to run the examples against your account.
217+
162218
[SendGrid Documentation](http://www.sendgrid.com/docs)
163219

164220
This readme adapted from [How to Send Email Using SendGrid with Windows Azure](http://www.windowsazure.com/en-us/develop/net/how-to-guides/sendgrid-email-service/)

0 commit comments

Comments
 (0)