summaryrefslogtreecommitdiffstats
path: root/examples/alerts
diff options
context:
space:
mode:
Diffstat (limited to 'examples/alerts')
-rw-r--r--examples/alerts/alerts.cs5
1 files changed, 5 insertions, 0 deletions
diff --git a/examples/alerts/alerts.cs b/examples/alerts/alerts.cs
index 26bd8f2..49766a7 100644
--- a/examples/alerts/alerts.cs
+++ b/examples/alerts/alerts.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);
@@ -13,6 +14,8 @@ string data = @"{
'frequency': 'daily',
'type': 'stats_notification'
}";
+Object json = JsonConvert.DeserializeObject<Object>(data);
+data = json.ToString();
dynamic response = sg.client.alerts.post(requestBody: data);
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
@@ -36,6 +39,8 @@ Console.ReadLine();
string data = @"{
'email_to': 'example@example.com'
}";
+Object json = JsonConvert.DeserializeObject<Object>(data);
+data = json.ToString();
var alert_id = "test_url_param";
dynamic response = sg.client.alerts._(alert_id).patch(requestBody: data);
Console.WriteLine(response.StatusCode);