Webhooks for slack integration is throwing 400 error
Thanks for opening this issue! If you would like to help implement an improvement, read more about contributing and consider submitting a pull request.
Not sure what you mean
I am seeing the same thing actually from our internal webhooks, I think it's slack side.
Any update? The same issue when we hit from BB
I got the same, slack returns
Response headers: Content-Type: text/html Transfer-Encoding: chunked Connection: close Date: Tue, 28 May 2019 02:28:21 GMT Server: Apache Vary: Accept-Encoding Strict-Transport-Security: max-age=31536000; includeSubDomains; preload Referrer-Policy: no-referrer X-Frame-Options: SAMEORIGIN Access-Control-Allow-Origin: * X-Via: haproxy-www-icn9 X-Cache: Error from cloudfront Via: 1.1 107e6221a3918b7fdc812d78ae3e5448.cloudfront.net (CloudFront) Response body:
Same here
If you're using GitHub Enterprise, you need to use the Slack app called "GitHub Notifications (Legacy)"
Same here
I can post to webhook with curl in terminal. 400 error in github
Headers Access-Control-Allow-Origin: * Connection: keep-alive Content-Length: 7 Content-Type: text/html Date: Wed, 29 Jan 2020 04:49:34 GMT Referrer-Policy: no-referrer Server: Apache Strict-Transport-Security: max-age=31536000; includeSubDomains; preload Transfer-Encoding: chunked Vary: Accept-Encoding Via: 1.1 05a90e634e0872685ad69ee9a4e0eba5.cloudfront.net (CloudFront) X-Amz-Cf-Id: df1Lkn1oT1mINwavBqDQI_nyNYC0bnoYlhBnxQWixA0fLAXZxzwnzg== X-Amz-Cf-Pop: IAD89-C2 X-Cache: Error from cloudfront X-Frame-Options: SAMEORIGIN X-Slack-Backend: h X-Via: haproxy-www-a57w Body no_text
@gimenete @wilhelmklopp ping? Any idea where to start?
I can post to webhook with
curlin terminal. 400 error in githubHeaders Access-Control-Allow-Origin: * Connection: keep-alive Content-Length: 7 Content-Type: text/html Date: Wed, 29 Jan 2020 04:49:34 GMT Referrer-Policy: no-referrer Server: Apache Strict-Transport-Security: max-age=31536000; includeSubDomains; preload Transfer-Encoding: chunked Vary: Accept-Encoding Via: 1.1 05a90e634e0872685ad69ee9a4e0eba5.cloudfront.net (CloudFront) X-Amz-Cf-Id: df1Lkn1oT1mINwavBqDQI_nyNYC0bnoYlhBnxQWixA0fLAXZxzwnzg== X-Amz-Cf-Pop: IAD89-C2 X-Cache: Error from cloudfront X-Frame-Options: SAMEORIGIN X-Slack-Backend: h X-Via: haproxy-www-a57w Body no_text
As far as I know, Slack requires {"text": "Your message here" } in your payload.
Check your Recent Deliveries in Github, and see one of the request payload, you will not see any attribute called text. That's just how Github works.
I have the same problem and I don't know how to work this out, too.
I would lean to just using Github App in Slack.
Man... from 2019-now 2021 still no option for that ? i have some issues.. i dont know how to solved it
same here
Here is a proxy workaround - very simple one
you can test it with https://www.offline.news/api/proxy/webhook/github2slack/SLACK_KEY
(the slack key is in the form of A/B/C)
var https = require('https');
// const request = require('request');
var bodyParser = require('body-parser');
const app = express()
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
// ...
app.post('/api/proxy/webhook/github2slack/:slackkeyA/:slackkeyB/:slackkeyC', (req, res) => {
const slackkeyA = req.params.slackkeyA;
const slackkeyB = req.params.slackkeyB;
const slackkeyC = req.params.slackkeyC;
const data = JSON.stringify({
text: `PR ${req.body.pull_request.state} by ${req.body.pull_request.user.login}: ${req.body.pull_request.title} - url:${req.body.pull_request.url}`
})
const options = {
hostname: 'hooks.slack.com',
port: 443,
path: `/services/${slackkeyA}/${slackkeyB}/${slackkeyC}`,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
}
const req2 = https.request(options, res2 => {
res2.on('data', d => {
res.setHeader('Content-Type', 'application/json');
res.send(d);
})
})
req2.on('error', error => {
console.error(error)
})
req2.write(data)
req2.end()
});
2022/06/04 still not working.
Solution:
- Remove "Content-Type" header
- body should be a stringified object with one key "text" and a string value
body: JSON.stringify({ text: 'some string...' })
Use integrations instead of a custom webhook, they have one specifically for slack that will send the text property on the body
2023/05/27 still not working.
Still not working same error. Body missing_text_or_fallback_or_attachments
Still same issue