Webhook Returns Error 400
I am a game developer for a text-based roleplaying game (MUD) and I use git for revision control. I am currently working on a post-receive hook that will take the newest commits pushed to the repository and, with a little formatting, post them to our game's Discord server via webhook.
The script is written and everything seems to work, except for the POST to the discord server. It is giving me 400 Client Error: BAD REQUEST for url: (Webhook Url)
I would appreciate any help in debugging this problem and getting the script to properly post to my discord server. Thank you!
https://pastebin.com/t8u9Q7ig <<-- The Script
https://pastebin.com/Y2yq0HFw <<-- The output of manually cURLing the outputted json
https://pastebin.com/3Cvhi2RZ <<-- The JSON outputted by script
All identifying info has been replaced by (-- INFO --) in the pastes.
-
You can setup a webhook between Discord and Github easily (note: /github MUST be added to the end of the webhook url when you put it in github!)
As for your issue here, you cannot use mailto links as the url there, you can only use http and https links. It works fine when I replace them with regular urls. image
If you look at the response, it tells you which embed the error is in.
3 -
Thank you for your response.
I do not use github. This is a private repository and although I want commit messages posted, i don't wish to share the entire code.
As for the issue, I had figured that out myself a few minutes ago, and have been arguing with a new issue..
It accepts the payload, but only prints the first embed item. I'm sure i'll get it figured out though. Going through it with a hammer for some percussive maintenance.
Thanks for your help.
0 -
It only accepts one of those embed objects, it's an array because of the other types (ex: link embeds), it just tosses the others out
1 -
AHA!
Alright. So removing the URL of the embed made it work the way i was expecting. It now posts all commits updated in the current push as one message, each commit a separate embed. (previously i had it sending a separate message for each commit.. but when i do 6 commits before pushing, it gets ... annoying.)
Thank you so much!
0 -
Ah, sorry about my misinformation, I though you could only use one embed
0
Iniciar sesión para dejar un comentario.
Comentarios
5 comentarios