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

Error 500 object has no attribute 'encode' #225

Open
maudrid opened this issue Nov 30, 2020 · 4 comments
Open

Error 500 object has no attribute 'encode' #225

maudrid opened this issue Nov 30, 2020 · 4 comments

Comments

@maudrid
Copy link

maudrid commented Nov 30, 2020

❓ Question

AirNotifier 2.x

Hi there.
I'm getting an error when using the push API.
The message is still pushed and arrives at the destination, but the API Response is 500.
Here is a debug log:

2020-11-30 15:28:47,306 - DEBUG - AirNotify POST URL: http://airnotifier:8801/api/v2/push
2020-11-30 15:28:47,307 - DEBUG - AirNotify Payload: {'device': 'fcm', 'token': 'my registered token', 'alert': 'My Message', 'badge': 1}
2020-11-30 15:28:47,641 - WARNING - Failed to send AirNotify notification: Internal server error., error=500.
2020-11-30 15:28:47,641 - DEBUG - Response Details:
b'{"error": "\'bytes\' object has no attribute \'encode\'"}'

Any idea what this may be?

@SavvyEngineer
Copy link

same here @maudrid did you find any solution?

@SavvyEngineer
Copy link

SavvyEngineer commented Jun 26, 2021

[I 210626 20:14:56 dao:25] find token: fduxKoZZRiSp39kCYLHNKz:APA91bFv-C88mkeQyQvLC92UyGuvnalXj3F4K_i7oJPx1h5It6EelKs-1fhnHCd1zGlG07Zy_5wJs5x_rWk7hHe37SV-ZAvMUroTzpSB5GgHbsR4t4TCP9vLgA2P-_Q7-Xf5Q0Pnzqf-
[I 210626 20:14:56 push:111] sending notification to fcm: fduxKoZZRiSp39kCYLHNKz:APA91bFv-C88mkeQyQvLC92UyGuvnalXj3F4K_i7oJPx1h5It6EelKs-1fhnHCd1zGlG07Zy_5wJs5x_rWk7hHe37SV-ZAvMUroTzpSB5GgHbsR4t4TCP9vLgA2P-_Q7-Xf5Q0Pnzqf-
[E 210626 20:14:56 push:177] Traceback (most recent call last):
      File "/root/airnotifier/api/push.py", line 116, in post
        fcmconn = self.fcmconnections[self.app["shortname"]][0]
    IndexError: list index out of range
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/root/airnotifier/api/push.py", line 119, in post
        statuscode = ex.code
    AttributeError: 'IndexError' object has no attribute 'code'
     'IndexError' object has no attribute 'code'
[E 210626 20:14:56 web:2242] 500 POST /api/v2/push (178.173.152.3) 16.97ms
[I 210626 20:14:56 __init__:217] PushHandler call ends 0.016781330108642578

@maudrid
Copy link
Author

maudrid commented Jun 27, 2021 via email

@SavvyEngineer
Copy link

@maudrid thanks for the reply I found out that I was using my firebase server key in Firebase Cloud Messaging settings and it was wrong then I looked back in the Docs of Installation 3.x and I found out that I had to do it this way Get the json key file from "Project settings" => "Service accounts", then generate the private key, download the json file, and copy paste content to airnotifier FCM settings.

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

No branches or pull requests

2 participants