Using SendGrid V1 and C # how do I delete an email from the lists without knowing the type?

0

Using SendMail V1 and C # as follows I can know if an email is on the bounces list and I get information:

var client = new SendGridClient(this.apiKey);
var response = client.RequestAsync(method: SendGridClient.Method.GET, urlPath: "suppression/bounces/" + email).GetAwaiter().GetResult();
dynamic dynJson = JsonConvert.DeserializeObject(response.Body.ReadAsStringAsync().Result);

Now I want to delete a single mail from the lists no matter what kind it is. How do I prepare the request to make that elimination?

    
asked by Marck Vit 19.09.2018 в 23:18
source

1 answer

1

If you use the SendGrid API

sendgrid-csharp

you could do it, analyze the example that is in github

suppression

// Delete a bounce
// DELETE /suppression/bounces/{email}

string queryParams = @"{
  'email_address': '[email protected]'
}";
var email = "test_url_param";
var response = await client.RequestAsync(method: SendGridClient.Method.DELETE, urlPath: "suppression/bounces/" + email, queryParams: queryParams);
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
Console.WriteLine(response.Headers.ToString());
Console.ReadLine();

In the examples there are several cases I do not know if the one I put is just what you are looking for, but I think it is closer because it performs the DELETE, but analyzes the others, but I see that in some cases first performs the GET to then put together the DELETE message

    
answered by 19.09.2018 в 23:52