VE 8.3: unable to send notification to discord webhook

Hey NullBy7e!

I could reproduce the problem by setting up a Discord webhook endpoint myself. It seems like that Discord has a problem with escaping characters and is more stricter on the webhook request body, so to fix this problem you can use the escape helper on the two properties in the request body like so:

JSON:
{"content":null,"embeds":[{"title":"```{{ escape title }}```","description":"```{{ escape message }}```","color":null,"footer":{"text":"Proxmox"}}],"attachments":[]}
 
  • Like
Reactions: NullBy7e and fiona
For further reference, I want to briefly illustrate why escape is needed.

If you use {{ message }} in the body template, it will be expanded to to the full notification message content. For illustrative purposes, let's assume that the notification content is

Code:
Backup finished.

Visit the web interface for more details.

Let's assume that you want to include this message in a JSON payload:

Code:
{
  "body": "{{ message }}"
}

When the body template is rendered, the result would be the following:

Code:
{
  "body": "Backup finished
 
Visit the web interface for more details"
}

As you can see, the result is a malformed JSON payload, because the message contained in {{ message }} contains line breaks and also potentially other characters that need to be escaped.

Now, if we change the body template as follows:
Code:
{
  "body": "{{ escape message }}"
}

then the control characters will be escaped properly, resulting in valid JSON:

Code:
{
  "body": "Backup finished\nVisit the web interface for more details"
}


I hope this helps!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!