containrrr / shoutrrr

Notification library for gophers and their furry friends.
https://containrrr.dev/shoutrrr/
MIT License
1.02k stars 60 forks source link

Cannot send notifications through discord with json #422

Open hoangdangtrungvn opened 11 months ago

hoangdangtrungvn commented 11 months ago

I config Discord service with url: WATCHTOWER_NOTIFICATION_URL: "discord://${DISCORD_WEBHOOK_TOKEN}@${DISCORD_WEBHOOK_ID}?json=true"

Then I got this error: level=error msg="Failed to send shoutrrr notification" error="failed to send discord notification: response status code 400 Bad Request" index=0 notify=no service=discord

But if I remove ?json=true from the URL, the notification is successfully sent to the Discord channel.

I tried replacing json=true with splitlines=false, and it worked fine.

It seems that some query parameters are not functioning correctly.

piksel commented 11 months ago

The json argument means that it should directly send the template output to the API (which then needs to be correct JSON). What is it you want to accomplish?

hoangdangtrungvn commented 11 months ago

Screenshot from 2023-12-14 14-17-58

I want to display like last message in the image.

piksel commented 11 months ago

Try adding `` around the messages in the watchtower template. You can probably get it to work using thejson` param and a carefully crafted template according to the discord docs, but it seems like a lot of work.