-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send grid not working with python 3.5.2 #782
Comments
Hello @dijaitly, The equivalent code in sendgrid-python v6.0.2 can be found here. You would be replacing: mail = Mail(from_email, subject, to_email, content) with mail = Mail(from_email, to_email, subject, content) and data = mail.get()
response = sg.client.mail.send.post(request_body=data) with response = sg.send(mail) With Best Regards, Elmer |
Hi followed the insturction on link it works.. I followed the instruction on the link provided.. it works.. thanks.. |
Seems like a crazy breaking change (reordering parameters) to push out to people automatically via a new package version. |
Hello @stefangordon, Please see this issue with respect to the refactor. Since we hope to very rarely make breaking changes, I tried to fix bad design issues while we had the hood up, so to speak. One of those bad decisions was the original ordering of the parameters. We used the semver custom of specifying a major version bump to avoid breaking changes being introduced to folks via auto-update. In your case, how did this major version bump slip through into production? I'd like to learn from you to avoid this issue in the future (that said, I'm really hoping we don't need a breaking change in the foreseeable future). Thanks for the feedback! With Best Regards, Elmer |
Thanks @thinkingserious, I understand sometimes it is necessary to make these changes. In my case we publish a library on PyPi and we do not pin any package versions as we understand it to be best practice - as such the library just stopped working for users after a deployment one day. I suppose if you want to make this change you could make an entirely new method name with your new parameters and mark the old one as deprecated for a while so people have lots of time to see warnings about deprecation before it goes away. Of course this makes it take much longer to complete the transition. |
Hello @stefangordon, Thank you for taking the time to provide thoughtful feedback, I really appreciate it! I've added your thoughts to our internal notes around improving our developer experience around our helper libraries. Cheers! With Best Regards, Elmer |
edit: NVM, i see that there were substantial changes to the API .. I fixed my code. |
It's safer to always specify the arg name when calling a function. It increases readability and order doesn't matter. |
Hi ,
I am trying to send email using following code in python version 3,5,2 and sendgrid 6.0.2
from sendgrid import *
from sendgrid.helpers.mail import *
import base64
import sys
from_email = Email("from")
to_email = Email("t0")
subject = "Sending with SendGrid is Fun"
content = Content("text/plain", "a")
mail = Mail(from_email, subject, to_email, content)
sg = sendgrid.SendGridAPIClient("key")
data = mail.get()
response = sg.client.mail.send.post(request_body=data)
it is giving me following error
TypeError: <sendgrid.helpers.mail.email.Email object at 0x000001B5D47A7668> is not JSON serializable
The text was updated successfully, but these errors were encountered: