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

Serialize payload to JSON formatted string #48

Closed
wants to merge 2 commits into from

Conversation

HackAfro
Copy link

@HackAfro HackAfro commented Jul 28, 2018

I realized that anytime my payload is in a dict format, I get this error while trying to send notifications.

Imgur

To fix this issue, I had to use json.dumps on the payload. So I suggest either we fix the issue or advice the user to serialize the payload

I realized that anytime my payload is in a dict format, I get this error while trying to send notifications. 

![Imgur](https://i.imgur.com/v0BRyJl.png)

To fix this issue, I had to use `json.dumps` on the payload. So I suggest either we fix the issue or advice the user to serialize the payload
Serialize payload to JSON formatted string
@safwanrahman
Copy link
Owner

In the documentation, its mentioned to import the function from webpush import send_user_notification not from utils. Its making the json.dump if you import directly from __init__.py. Check the __init__.py please.

@HackAfro
Copy link
Author

I didn't import from utils. Here's what my imports look like:

Imports list

I'm not importing directly from utils. This has happened a few times in a few of my projects and I had to spend time searching for the origin of the issue

@HackAfro
Copy link
Author

Oh I see my mistake. I'm meant to import send_user_notification and not send_notification_to_user. That fixes it.

@safwanrahman
Copy link
Owner

@HackAfro So I think this PR should be closed? what do you think?

@HackAfro
Copy link
Author

Sure

@HackAfro HackAfro closed this Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants