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] Bad Request: can't parse entities #190

Open
euphoria360 opened this issue May 7, 2024 · 3 comments
Open

[Error] Bad Request: can't parse entities #190

euphoria360 opened this issue May 7, 2024 · 3 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@euphoria360
Copy link

euphoria360 commented May 7, 2024

🪲 Describe the bug
I am using Apprise API Docker on my home server to send messages to my Telegram Group.
A script on another system sends messages to it using curl post command.
Everything was working fine until around April 17th when messages stopped coming.
Today I started looking at the script and saw that Apprise complains about characters in the message.
the message is:

*Home-S [Sonarr]:* Test
Testing if Sonnar can Send us any Massage.
If you got this, then Hurrayyyyy!!!

It is being sent to Apprise via this command:
printf "$message\n" | curl -X POST -F "body=$(</dev/stdin)" "$appriseurl"

And this is the error:

2024-05-07 12:04:36,241 [INFO] apprise: Loaded 1 entries from memory://
2024-05-07 12:04:37,340 [WARNING] apprise: Failed to send Telegram notification to -1001234567890: Bad Request: can't parse entities: Character '-' is reserved and must be escaped with the preceding '\', error=400.

I tried to send a simple message via curl and again same happened:

curl -X POST -F "body=home-s" "http://192.168.48.6:8008/notify/tg-nasbot"

2024-05-07 12:15:01,689 [INFO] apprise: Loaded 1 entries from memory://
2024-05-07 12:15:02,728 [WARNING] apprise: Failed to send Telegram notification to -1001847463926: Bad Request: can't parse entities: Character '-' is reserved and must be escaped with the preceding '\', error=400.

If I remove '-', other characters like []: will get complains too. this was not the case before.
what should I do?

💻 Your System Details:

  • OS: Apprise API Docker container

Update:
I finally fixed it by piping my message through sed and escaping all special characters. So far it works:
printf "$message\n" | sed "s|[-.\!()%&#?/@+':]|\\\&|g" | curl -X POST -F "body=$(</dev/stdin)" "$appriseurl"

@euphoria360 euphoria360 added the bug Something isn't working label May 7, 2024
@caronc
Copy link
Owner

caronc commented May 7, 2024

Are you passing in a - on the URL?

@euphoria360
Copy link
Author

yes. for example, in this command curl -X POST -F "body=home-s" "http://192.168.48.6:8008/notify/tg-nasbot"
the - is passed as part of home-s word

If I escape the - as Apprise says, like curl -X POST -F "body=home\-s" "http://192.168.48.6:8008/notify/tg-nasbot"
the command runs successfully.
But the problem is that the messages sent by the script are dynamic and I don't know the content beforehand. Also, I don't know what characters Apprise doesn't like.

@caronc
Copy link
Owner

caronc commented May 14, 2024

I can't reproduce this at all

curl -X POST -F "body=home-s" -F tag=telegram "http://localhost:8000/notify/chris"
2024-05-13 19:08:42,013 [INFO] apprise: Loaded 3 entries from memory://
2024-05-13 19:08:42,515 [INFO] apprise: Sent Telegram notification.

In the above example, i map the telegram tag so that i only send a notificatoin there, but even if i drop the tags, the dash in the body has no problem (and does not need to be escaped at all.

Also, I don't know what characters Apprise doesn't like.

To ansewr this, there is nothing it doesn't like 😉 . It just passes things along . There is something else happening in your case. I'm in an Linux environment for my test, are you in the same ?

Instead of using curl... just as a test, try installing hte local apprise tool and see if you can get more details out of the logs:

pip install apprise

# -vvvv is a very, very verbose output
# you can possibly test your command you were doing too;
# if no -b (--body) is specified, then stdin is used by default, so the below should work fine:
printf "$message\n" | sed "s|[-.\!()%&#?/@+':]|\\\&|g" | apprise -vvvv "$appriseurl"

@caronc caronc added the invalid This doesn't seem right label May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants