小编use*_*202的帖子

Slack没有有效载荷接收到nodejs

所以使用curl我可以成功发送post请求到slack

curl -X POST --data-urlencode 'payload={"channel": "#tech-experiment", "username": "at-bot", "text": "This is posted to #general and comes from a bot named webhookbot.", "icon_emoji": ":ghost:"}' https:/company.slack.com/services/hooks/incoming-webhook?token=dddddddd2342343
Run Code Online (Sandbox Code Playgroud)

但是当我使用nodejs将其转换为代码时

var request = require('request');
var http = require('http');
var server = http.createServer(function(req, response){
    response.writeHead(200,{"Content-Type":"text/plain"});
    response.end("end");
});

option = {
    url: 'https://company.slack.com/services/hooks/incoming-webhook?token=13123213asdfda',
    payload: '{"text": "This is a line of text in a channel.\nAnd this is another line of text."}'
}

request.post(
    option,

    function (error, response, body) {
        if (!error && response.statusCode == 200) {
            console.log(body) …
Run Code Online (Sandbox Code Playgroud)

curl node.js slack-api

3
推荐指数
2
解决办法
3366
查看次数

标签 统计

curl ×1

node.js ×1

slack-api ×1