-
-
Notifications
You must be signed in to change notification settings - Fork 375
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom fields in custom notifications #842
Comments
Hmm... not sure the best way to do this. Perhaps if you use the payload over-ride keywords on one of the system ones, it just renames it? For example: This would allow me to re-use the existing payload over-ride tokens. This would work with for Would that work? |
Edit: ignore this message. |
You want to use the |
Ok, ignore my last message. It turns out that the server accepts JSON data but I was missing the header I need to change {
"user" : "...",
"pass" : "...",
"msg" : "..."
} needs to be passed. Any additional field is ignored. Here is what I tried, it doesn't seem to work well :/ # Sends the word "message"
www-data@apprise:/opt/apprise$ apprise -vvv -b "BODY" \
"jsons://smsapi.free-mobile.fr/sendmsg?:user=ABC&:pass=DEF&:msg=message"
2023-03-19 00:20:19,883 - DEBUG - Loaded JSON URL: jsons://smsapi.free-mobile.fr/sendmsg?method=POST&format=text&overflow=upstream&rto=4.0&cto=4.0&verify=yes&%3Auser=ABC&%3Apass=DEF&%3Amsg=message
2023-03-19 00:20:19,884 - DEBUG - Using selector: EpollSelector
2023-03-19 00:20:19,885 - INFO - Notifying 1 service(s) asynchronously.
2023-03-19 00:20:19,891 - DEBUG - JSON POST URL: https://smsapi.free-mobile.fr/sendmsg (cert_verify=True)
2023-03-19 00:20:19,892 - DEBUG - JSON Payload: {'version': '1.0', 'title': '', 'message': 'BODY', 'attachments': [], 'type': 'info', 'user': 'ABC', 'pass': 'DEF', 'msg': 'message'}
2023-03-19 00:20:20,149 - INFO - Sent JSON POST notification.
# Sends the word ":message"
www-data@apprise:/opt/apprise$ apprise -vvv -b "BODY" \
"jsons://smsapi.free-mobile.fr/sendmsg?:user=ABC&:pass=DEF&:msg=:message"
2023-03-19 00:20:19,883 - DEBUG - Loaded JSON URL: jsons://smsapi.free-mobile.fr/sendmsg?method=POST&format=text&overflow=upstream&rto=4.0&cto=4.0&verify=yes&%3Auser=ABC&%3Apass=DEF&%3Amsg=%3Amessage
2023-03-19 00:20:19,884 - DEBUG - Using selector: EpollSelector
2023-03-19 00:20:19,885 - INFO - Notifying 1 service(s) asynchronously.
2023-03-19 00:20:19,891 - DEBUG - JSON POST URL: https://smsapi.free-mobile.fr/sendmsg (cert_verify=True)
2023-03-19 00:20:19,892 - DEBUG - JSON Payload: {'version': '1.0', 'title': '', 'message': 'BODY', 'attachments': [], 'type': 'info', 'user': 'ABC', 'pass': 'DEF', 'msg': ':message'}
2023-03-19 00:20:20,149 - INFO - Sent JSON POST notification.
# Fails to send anything because the field "msg" is missing
$ www-data@apprise:/opt/apprise$ apprise -vvv -b "BODY" \
"jsons://smsapi.free-mobile.fr/sendmsg?:user=ABC&:pass=DEF&:message=msg"
2023-03-19 00:33:02,268 - DEBUG - Loaded JSON URL: jsons://smsapi.free-mobile.fr/sendmsg?method=POST&format=text&overflow=upstream&rto=4.0&cto=4.0&verify=yes&%3Auser=ABC&%3Apass=DEF&%3Amessage=msg
2023-03-19 00:33:02,269 - DEBUG - Using selector: EpollSelector
2023-03-19 00:33:02,270 - INFO - Notifying 1 service(s) asynchronously.
2023-03-19 00:33:02,276 - DEBUG - JSON POST URL: https://smsapi.free-mobile.fr/sendmsg (cert_verify=True)
2023-03-19 00:33:02,277 - DEBUG - JSON Payload: {'version': '1.0', 'title': '', 'message': 'msg', 'attachments': [], 'type': 'info', 'user': 'ABC', 'pass': 'DEF'}
2023-03-19 00:33:02,506 - WARNING - Failed to send JSON POST notification: Bad Request - Unsupported Parameters., error=400.
2023-03-19 00:33:02,507 - DEBUG - Response Details:
b''
# Same thing when setting ":message=:msg" |
Have a look at the latest Pull request (attached to this ticket); this will solve your problem going forward. In your case, you're URL would just need to look like:
The above would:
Giving you the output: {
"user" : "...",
"pass" : "...",
"msg" : "..."
} |
Closing off this ticket as it works great for me (added test cases too)! 馃檪 馃殌 |
Thank you so much 馃殌 |
that's very cool! |
馃挕 The Idea
From https://github.com/caronc/apprise/wiki/Notify_Custom_JSON, the important fields
title
andmessage
are fixed.Some services support different fields. For example, #652 only supports
msg
instead ofmessage
.Ideally, being able to redirect
title
andmessage
to other variables would be great, but at least being able to rename these fields would be a great start.Currently, I don't see how to do #652 with the Custom JSON without this.
馃敤 Breaking Feature
None
The text was updated successfully, but these errors were encountered: