Sending JSON to Slack in a HTTP POST request

后端 未结 11 783
隐瞒了意图╮
隐瞒了意图╮ 2020-12-24 05:21

I\'m trying to send a message using Slack\'s chat.postMessage API call. I have no problems encoding my test messages within HTTP GET, but I\'m trying to achieve the same res

11条回答
  •  梦谈多话
    2020-12-24 05:53

    I'm a bit late, but I hope this can help other people who stumble into this issue like me. I've just been in touch with Slack, and this is what they told me:

    The Slack Web API doesn't accept JSON data at all — so along with changing the Content-Type those variables should be posted using standard HTTP form attributes.

    We plan to support JSON data in the future for consistency in the future.

    So, your cURL line should look like:

    curl -X POST -d 'token=my-token-here&channel=#channel-name-or-id&text=Text here.&username=otherusername'`
    

    I hope this helps! :)

提交回复
热议问题