0

I'm currently trying to setup Discord(or Slack-like) webhooks with my Fossil Repo running 2.6

I'm following this documentation:

Here's an example of what I'm trying to run in the raw TH1 requests:

http -asynchronous https://discordapp.com/api/webhooks/443395012672094208/(redacted) {content: 'hello there'}

Which I'm hoping for it to look something like this(I did this in Postman separately)

ideal

However I get no response and there's not much room for debugging on Fossil. I wasn't sure exactly how to format the payload. I tried "stringifying" it as well. Synchronous requests to see the HTTP response are not yet implemented so I cannot take off the flag.

I have my TH1 Regexp setup as follows(it throws no error about unacceptable URI anymore):

TH1 Regexp

Jacob Morrison
  • 610
  • 2
  • 10
  • 19

2 Answers2

2

This is a guess: you may want

http -asynchronous $url {{"content":"hello there"}}

The double brackets are not a mistake: The outer braces are TH1's quotes, and the inner content is a JSON object (I'm assuming you are meant to POST some JSON data to the discord webhook).

You might want to link to the discord webhook REST API to see what payload you should be sending.

glenn jackman
  • 238,783
  • 38
  • 220
  • 352
  • Reading [the docs](https://github.com/discordapp/discord-api-docs/blob/master/docs/resources/Webhook.md) (i.e., without logging into the Discord system) I see that the content type of the POSTed data needs to be correct. But apart from that, the problem was the lack of the extra braces. – Donal Fellows May 08 '18 at 17:19
  • Thanks for the feedback, I wasn't aware I'd need the double curly brackets. However I think the issue is the Content-Type header isn't specified as a multipart-formdata as noted in the docs(I've updated to link them): `It does require multipart/form-data requests instead of the normal JSON request type when uploading files.` – Jacob Morrison May 08 '18 at 17:47
  • I wonder if you'll have to use `tclInvoke` to get to Tcl's [http](https://tcl.tk/man/tcl8.6/TclCmd/http.htm) command' – glenn jackman May 08 '18 at 18:13
  • What content type is it using? – Donal Fellows May 09 '18 at 01:11
0

While I appreciated the feedback I got from the comments both here and Fossil SCM forums, I found the best way to get around this was to send updates to a "middleware" service that gets the last updated ticket via command line and parses the ticket history and sends that information to the webhook like that. I'd like to see if anyone else ever solves this issue.

Jacob Morrison
  • 610
  • 2
  • 10
  • 19