# Post commits via webhook inside a topic as reply

**URL:** https://meta.discourse.org/t/post-commits-via-webhook-inside-a-topic-as-reply/156821
**Category:** Support
**Created:** [July 5, 2020, 9:16am UTC](https://meta.discourse.org/t/post-commits-via-webhook-inside-a-topic-as-reply/156821 "2020-07-05T09:16:58Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![B-iggy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/b-iggy/32/201234_2.png) [@B-iggy](https://meta.discourse.org/u/B-iggy)
#### Post date: [July 5, 2020, 9:16am UTC](https://meta.discourse.org/t/post-commits-via-webhook-inside-a-topic-as-reply/156821/1 "2020-07-05T09:16:58Z")

</div>

Hey guys,  
I searched but couldn’t find the proper direction.

I want to automatically post a reply inside a topic as soon as I pushed a commit on a github repository - automatically via a webhook.

I work with Integromat and already successfully did something similar [with topics](https://meta.discourse.org/t/compose-a-new-pre-filled-topic-via-url/28074)

I have setup an API in Discourse, a webhook in Github, a HTTP POST scenario in Integromat but I’m missing the final piece to make it work.

My current attempt looks like this which does not work.

 ![image](https://global.discourse-cdn.com/meta/original/3X/2/0/20e8ff394864ec3b2ca044f0729508f5a3ce56ba.png)

I think because Discourse does not know what to do with the POST request.  
I mean there is /new-message? and /new-topic? but not /new-reply?

Maybe it’s something trivial, thanks in advance for your help!

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [July 5, 2020, 9:37am UTC](https://meta.discourse.org/t/post-commits-via-webhook-inside-a-topic-as-reply/156821/2 "2020-07-05T09:37:42Z")

</div>

You can find out how to construct your request by reverse engineering the Discourse API. Basically you open your network inspector, post a reply to a topic and see what happens under the hood:

> [@Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576):
>
> Discourse is backed by a complete JSON api. Anything you can do on the site you can also do using the JSON api. The API is documented at [docs.discourse.org](https://docs.discourse.org). You can also use the [discourse\_api](https://github.com/discourse/discourse_api) Ruby gem as a client library. However, not every endpoint is documented. To determine how to do something with the JSON API here are some steps you can follow. Example: recategorize a topic. Go to a topic and start editing a category: Open Chrome dev tools, switch to the Network tab, select …

---

<div class="post-metadata">

### Author: ![B-iggy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/b-iggy/32/201234_2.png) [@B-iggy](https://meta.discourse.org/u/B-iggy)
#### Post date: [July 5, 2020, 9:42am UTC](https://meta.discourse.org/t/post-commits-via-webhook-inside-a-topic-as-reply/156821/3 "2020-07-05T09:42:47Z")

</div>

Thanks a lot @bartv  
Just doing it right now 🙂

Only question would be: are ALL fields mandatory to make a reply POST call? It’s quite a lot and some fields can’t be filled by me dynamically I think or are prone to mistakes!? (the id: for example)

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/1/41870fce42e7c95d556cb1013f14130cae961361.png)

In Zapier for example I made once a successful Topic POST Webhook with only those data fields

 ![image](https://global.discourse-cdn.com/meta/original/3X/2/8/28dfc5bc3bf2632731d1961b89bfb77598c4f650.png)

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [July 5, 2020, 9:44am UTC](https://meta.discourse.org/t/post-commits-via-webhook-inside-a-topic-as-reply/156821/4 "2020-07-05T09:44:30Z")

</div>

I doubt they’re all required. Just try it 🙂

---

<div class="post-metadata">

### Author: ![B-iggy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/b-iggy/32/201234_2.png) [@B-iggy](https://meta.discourse.org/u/B-iggy)
#### Post date: [July 5, 2020, 10:16am UTC](https://meta.discourse.org/t/post-commits-via-webhook-inside-a-topic-as-reply/156821/5 "2020-07-05T10:16:51Z")

</div>

Just as info it is not failing because of the data fields but because of bad csrf.  
See here:

> [@Improve BAD CSRF error message when making API calls with content-type application/json](https://meta.discourse.org/t/improve-bad-csrf-error-message-when-making-api-calls-with-content-type-application-json/117136):
>
> API requests with the Content-Type as “application/json” often receive an unhelpful message like “BAD CSRF”, so we should improve the error messaging so that it provides more details as to why they are receiving this error message.

@blake Does this mean I need to set the api\_username and api\_key in the Header?

My current progress which fails:

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/8/b8deb2530b283722f167357e7afbac6f1d2e8efa.png)

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [July 6, 2020, 3:47pm UTC](https://meta.discourse.org/t/post-commits-via-webhook-inside-a-topic-as-reply/156821/6 "2020-07-06T15:47:31Z")

</div>

Yep, you will need to set the `Api-Username` and `Api-Key` in the header. Be sure to change the `_` to a `-`. You will also need to remove the credentials from the body.

---

<div class="post-metadata">

### Author: ![B-iggy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/b-iggy/32/201234_2.png) [@B-iggy](https://meta.discourse.org/u/B-iggy)
#### Post date: [July 6, 2020, 4:35pm UTC](https://meta.discourse.org/t/post-commits-via-webhook-inside-a-topic-as-reply/156821/7 "2020-07-06T16:35:18Z")

</div>

**Awesome, thank you very much** @blake!  
That was it.

For someone searching for hours via Google and Search as I did, that’s it:

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/a/ea5d3bc4da68618dc73e23bff051cf464b7c8d92.png)

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/9/39848e48c36e7d2689e5c96d5dccf05458c11872.png)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [August 5, 2020, 4:35pm UTC](https://meta.discourse.org/t/post-commits-via-webhook-inside-a-topic-as-reply/156821/8 "2020-08-05T16:35:21Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
