So I get a bad request error whenever I run this. I have looked on stack overflow but can't seem to get any of the responses from users to work. Any help would be appreciated.
//Make a request to the SendGrid API to add the email address to the globabl unsubscirbe
HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create("https://api.sendgrid.com/v3/asm/suppressions/global");
request1.Headers.Add("authorization", "My_API_KEY");
string Data = "{" + "recipient_emails:[" + "\"" +(txtEmail.Text) + "\"" + "]}"; //place body here
request1.Method = "POST";
request1.ContentType = "application/json";
using (StreamWriter sw = new StreamWriter(request1.GetRequestStream()))
{
sw.Write(Data);
}
HttpWebResponse response1= (HttpWebResponse)request1.GetResponse();
using (var streamReader = new StreamReader(response1.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
result.ToString();
}