Open clairenied15 opened 5 years ago
This means your API key is not making it into your program correctly. Did you set the SENDGRID_API_KEY environment variable in the same terminal that you are running your server program in?
I'm not sure what you mean by setting the environment variable.
I copied my API key from sendgrid and replaced the SENDGRID_API_KEY variable in the sample code
Check out my latest email--if you leave things as they were in the SendGrid example code but set the environment variable as mentioned in the email you should be good to go!
I followed your instructions for setting the environment variable but am still getting the 401 error. This is my code:
`
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
from_email = Email("claire.niederriter@duke.edu")
to_email = Email("claireniederriter@ymail.com")
subject = "Tachycardia"
content = Content("text/plain", "and easy to do anywhere, even with Python")
mail = Mail(from_email, subject, to_email, content)
response = sg.client.mail.send.post(request_body=mail.get())
print(response.status_code)
print(response.body)
print(response.headers)`
I can't seem to get SendGrid to work. I copied the "With Mail Helper Class" code into my tachycardia function to run when the patient is tachycardic. I made my API key and put it in the code. The error that I'm getting says "HTTP Error 401: Unauthorized"