I am attempting to set up a webhook to Slack, but am getting an Error message of "Invalid_Payload"
I've looked through Stack, Slack, and Github... but cant' find the answer I seek.
"CustomLink" in there for privacy, actual link is begin used.
CODE:
var request = require('request')
var webhook = "https://hooks.slack.com/services/CUSTOMLINK"
var payload={"text":"This is via an integration from Me - It is a test"}
request.post({url: webhook, payload: payload}, function(err, res){
if(err){console.log(err)}
if(res){console.log(res.body)}
})
ERROR:
invalid_payload
The webhook only accepts data, and thus alone cannot expose sensitive data to third parties.
Your webhook URL contains a secret. Don't share it online, including via public version control repositories. Slack actively searches out and revokes leaked secrets.
While you can use legacy incoming webhooks to post messages, they do not have access to interactive messages features. To make your messages interactive, you'll need to create an incoming webhook with a Slack app instead. Please note: it's not possible to send files via webhook.
This worked for me
var payload = {"text":"Message to be sent"}
payload = JSON.stringify(payload);
request.post({url: url, body: payload},function(err,data){
console.log(data.body);
})
var payload= {"text":"This is via an integration from Me - It is a test"}
payload = JSON.stringify(payload)
I had forgot to stringify the JSON I was creating. Stupid Me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With