summaryrefslogtreecommitdiffstats
path: root/examples/apikeys/apikeys.cs
diff options
context:
space:
mode:
authorElmer Thomas <elmer@thinkingserious.com>2016-07-18 13:55:29 -0700
committerElmer Thomas <elmer@thinkingserious.com>2016-07-18 13:55:29 -0700
commit37d469751aa68a9dde800a9ea90c1301ec02177e (patch)
treee8124553b37701210a09efd7ce3dd35c841a968a /examples/apikeys/apikeys.cs
parentdbc798284527e3256d7cc57ab2e5d8e8cea58e8e (diff)
downloadsendgrid-csharp-37d469751aa68a9dde800a9ea90c1301ec02177e.zip
sendgrid-csharp-37d469751aa68a9dde800a9ea90c1301ec02177e.tar.gz
sendgrid-csharp-37d469751aa68a9dde800a9ea90c1301ec02177e.tar.bz2
Updated examples and Usage
Diffstat (limited to 'examples/apikeys/apikeys.cs')
-rw-r--r--examples/apikeys/apikeys.cs7
1 files changed, 7 insertions, 0 deletions
diff --git a/examples/apikeys/apikeys.cs b/examples/apikeys/apikeys.cs
index 67dce33..6538543 100644
--- a/examples/apikeys/apikeys.cs
+++ b/examples/apikeys/apikeys.cs
@@ -1,5 +1,6 @@
using System;
using SendGrid.Helpers.Mail; // If you are using the Mail Helper
+using Newtonsoft.Json; // You can generate your JSON string yourelf or with another library if you prefer
string _apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey);
@@ -17,6 +18,8 @@ string data = @"{
'alerts.read'
]
}";
+Object json = JsonConvert.DeserializeObject<Object>(data);
+data = json.ToString();
dynamic response = sg.client.api_keys.post(requestBody: data);
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
@@ -47,6 +50,8 @@ string data = @"{
'user.profile.update'
]
}";
+Object json = JsonConvert.DeserializeObject<Object>(data);
+data = json.ToString();
var api_key_id = "test_url_param";
dynamic response = sg.client.api_keys._(api_key_id).put(requestBody: data);
Console.WriteLine(response.StatusCode);
@@ -61,6 +66,8 @@ Console.ReadLine();
string data = @"{
'name': 'A New Hope'
}";
+Object json = JsonConvert.DeserializeObject<Object>(data);
+data = json.ToString();
var api_key_id = "test_url_param";
dynamic response = sg.client.api_keys._(api_key_id).patch(requestBody: data);
Console.WriteLine(response.StatusCode);