sendgrid/sendgrid-python

Issue while using API to get senders

Closed this issue · 2 comments

Issue Summary

I'm getting a HTTP Error 403: FORBIDDEN error when I'm using sg.client.senders.get() whereas sg.client.templates.get() is working.

Code Snippet

response = sg.client.senders.get()
print(response.status_code)
print(response.body)
print(response.headers)

Exception/Log

HTTP Error 403: FORBIDDEN

Found a Fix

There is an error in your senders.py file. The

response = sg.client.senders.get()

should be replaced with

response = sg.client.marketing.senders.get()

and it works fine.

I would suggest you make the necessary changes because that will be very helpful for the others referring to your documentation.

Hi @mahimaaapatel

The sg.client.senders.get() call hits the Legacy Marketing Campaigns /senders endpoint, which is still an active endpoint for older SendGrid accounts who have not yet migrated to New Marketing Campaigns, but is not available for new adoption, hence the 403 response. The sg.client.marketing.senders.get() call hits the New Marketing Campaigns /marketing/senders endpoint, which is applicable for newer SendGrid accounts. For more information, please reference the SendGrid API v3 documentation. You may note that there is a "Senders" section under the "New Marketing Campaigns" header (the endpoint you want to hit), as well as a "Sender Identities API" section under the "Legacy Marketing Campaigns" header.

Unfortunately we have not been able to add new auto-generated examples in a while, but I can assure you we have it in our backlog to do so! Sorry for the confusion and I'm glad you were able to find the right endpoint!

@eshanholtz Thank you for the clarification.