Skip to content

Latest commit

 

History

History
119 lines (76 loc) · 4.54 KB

TROUBLESHOOTING.md

File metadata and controls

119 lines (76 loc) · 4.54 KB

If you have an issue logging into your Twilio SendGrid account, please read this document. For any questions regarding login issues, please contact our support team.

If you have a non-library Twilio SendGrid issue, please contact our support team.

If you can't find a solution below, please open an issue.

Table of Contents

Environment Variables and Your Twilio SendGrid API Key

All of our examples assume you are using environment variables to hold your Twilio SendGrid API key.

If you choose to add your Twilio SendGrid API key directly (not recommended):

api_key=os.environ.get('SENDGRID_API_KEY')

becomes

api_key='SENDGRID_API_KEY'

In the first case, SENDGRID_API_KEY is in reference to the name of the environment variable, while the second case references the actual Twilio SendGrid API Key.

Error Messages

HTTP exceptions are defined in the python_http_client package.

To read the error message returned by SendGrid's API in Python 2.X:

from python_http_client.exceptions import HTTPError

try:
  response = sg.client.mail.send.post(request_body=mail.get())
except HTTPError as e:
    print e.to_dict

To read the error message returned by Twilio SendGrid's API in Python 3.X:

from python_http_client.exceptions import HTTPError

try:
  response = sg.client.mail.send.post(request_body=mail.get())
except HTTPError as e:
    print(e.to_dict)

Migrating from v2 to v3

Please review our guide on how to migrate from v2 to v3.

Continue Using v2

Here is the last working version with v2 support.

Using pip:

pip uninstall sendgrid
pip install sendgrid=1.6.22

Download:

Click the "Clone or download" green button in GitHub and choose download.

Testing v3 /mail/send Calls Directly

Here are some cURL examples for common use cases.

Using the Package Manager

We upload this library to PyPI whenever we make a release. This allows you to use pip for easy installation.

In most cases we recommend you download the latest version of the library, but if you need a different version, please use:

pip install sendgrid==X.X.X

If you are using a requirements file, please use:

sendgrid==X.X.X

Versioning Convention

We follow the MAJOR.MINOR.PATCH versioning scheme as described by SemVer.org. Therefore, we recommend that you always pin (or vendor) the particular version you are working with to your code and never auto-update to the latest version. Especially when there is a MAJOR point release, since that is guaranteed to be a breaking change. Changes are documented in the CHANGELOG and releases section.

Viewing the Request Body

When debugging or testing, it may be useful to examine the raw request body to compare against the documented format.

You can do this right before you call response = sg.client.mail.send.post(request_body=mail.get()) like so:

 print(json.dumps(message.get(), sort_keys=True, indent=4))

Error Handling

Please review our use_cases for examples of error handling.