我需要将以下curl查询编码为node.js请求。 我知道表单应该可以完成这项工作,但我不知道如何处理“payload =”
curl -X POST --data-urlencode 'payload={"channel": "#tutorial", "username": "webhookbot", "text": "This is posted to #tutorial and comes from a bot named webhookbot.", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/T5NGB8FE0/B6G57N86A/....
答案 0 :(得分:1)
也许是这样的:
request.post({
url: 'https://hooks.slack.com/services/T5NGB8FE0/B6G57N86A/',
form: {
payload: '{"channel": "#tutorial", "username": "webhookbot", "text": "This is posted to #tutorial and comes from a bot named webhookbot.", "icon_emoji": ":ghost:"}'
}
}, (error, response, body) => {
//your code
}
);