I have a sendgrid account which includes 7 days of email history. I try to get these with the api command:
var sendgridtask = sendgridclient.RequestAsync(method: SendGrid.SendGridClient.Method.GET, urlPath: "messages?limit=10");
but this gives the response:
{"errors":[{"message":"authorization required"}]}
I guess the api key isn't correct, but when I try to execute the command:
var sendgridtask = sendgridclient.RequestAsync(method: SendGrid.SendGridClient.Method.GET, urlPath: "suppression/bounces/" + email);
it gives no error and responses the right info. I checked the api key and it has full access.
I've also tried:
sendgridclient.AddAuthorization(new KeyValuePair<string, string>("Authorization", $"Bearer {apiKey}"));
but this gives the same response
Do you know what I am doing wrong?
Already got an answer from SendGrid:
Unfortunately in order to gain access to the Email Activity Feed API, you must purchase additional email activity history.
Or you can use our event webhook for your activity. https://sendgrid.com/docs/for-developers/tracking-events/getting-started-event-webhook/
So it seems that our license included history is only accessible from the SendGrid website, not from the API without an additional license.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With