sendgrid / sendgrid-java

The Official Twilio SendGrid Led, Community Driven Java API Library
https://sendgrid.com
MIT License
484 stars 408 forks source link

SOLVED - GET /messages/{msg_id} returns statusCode = 403 "access forbidden" #673

Closed icarrara closed 3 years ago

icarrara commented 3 years ago

Hello @thinkingserious

Please could you help me with the usage of GET /messages/{msg_id} ?

Using Java I got:

My code:

SendGrid sg = new SendGrid("SG.xxxxxxxxxxxxxxxxx");

Request request = new Request(); request.setMethod(Method.GET); request.setEndpoint("messages"); request.addQueryParam("query", "msg_id='ERsDbjjdQZ-sQW5X18erfA.filterdrecv-p3mdw1-7745b6f999-bnpxx-19-603139AC-6F.0'");

    try {

                  Response response=sg.api(request);

    } catch (IOException ioe) { }

Note that:

Thank you for any help

Originally posted by @icarrara in https://github.com/sendgrid/sendgrid-java/issues/425#issuecomment-782718871

icarrara commented 3 years ago

I had checked the key and I'm seeing it doesn't have Email Activity permissions. After editing the API key permissions and giving Read Access to the Email Activity permission, I was be able to access the API.