Skip to content
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

Closed
dijaitly opened this issue Apr 5, 2019 · 8 comments
Closed

Send grid not working with python 3.5.2 #782

dijaitly opened this issue Apr 5, 2019 · 8 comments
Labels
difficulty: unknown or n/a fix is unknown in difficulty status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library

Comments

@dijaitly
Copy link

dijaitly commented Apr 5, 2019

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

  • sendgrid-python Version: master (latest commit: [commit number]) 6.0.2
  • Python Version: 3.5.2
@thinkingserious
Copy link
Contributor

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

@thinkingserious thinkingserious added difficulty: unknown or n/a fix is unknown in difficulty status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library labels Apr 5, 2019
@dijaitly
Copy link
Author

dijaitly commented Apr 8, 2019

Hi followed the insturction on link it works..

I followed the instruction on the link provided..

it works.. thanks..

@dijaitly dijaitly closed this as completed Apr 8, 2019
@stefangordon
Copy link

Seems like a crazy breaking change (reordering parameters) to push out to people automatically via a new package version.

@thinkingserious
Copy link
Contributor

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

@stefangordon
Copy link

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.

@thinkingserious
Copy link
Contributor

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

@japrogramer
Copy link

japrogramer commented Jun 13, 2019

edit:

NVM, i see that there were substantial changes to the API .. I fixed my code.

@davegallant
Copy link

Seems like a crazy breaking change (reordering parameters) to push out to people automatically via a new package version.

It's safer to always specify the arg name when calling a function. It increases readability and order doesn't matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: unknown or n/a fix is unknown in difficulty status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library
Projects
None yet
Development

No branches or pull requests

5 participants