使用 httpotion elixir 发布到 slack api [英] post to slack api with httpotion elixir

查看:22
本文介绍了使用 httpotion elixir 发布到 slack api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里只是处理一个语法错误.尝试在 HTTPotion 请求的正文中发送有效负载.尝试将数据作为 json 发送,但不确定我哪里出错了.

Just dealing with a syntax error here. Trying to send the payload in the body of the HTTPotion request. Trying to send the data as json, but not really sure where I'm going wrong.

HTTPotion.post "https://hooks.slack.com/services/a00000/b0000/XXXXXXX", [body: "{'channel': '#general', 'username': 'thedanotto', 'text': 'Pokemon are scary!', 'icon_emoji': ':ghost:'}", ["Content-Type": "application/json"]]

=> ** (SyntaxError) iex:1: 之前的语法错误:'['

有什么想法吗?

推荐答案

您在标题列表之前缺少 headers:.这应该有效:

You're missing headers: before the headers list. This should work:

HTTPotion.post "https://hooks.slack.com/services/a00000/b0000/XXXXXXX", [body: "{'channel': '#general', 'username': 'thedanotto', 'text': 'Pokemon are scary!', 'icon_emoji': ':ghost:'}", headers: ["Content-Type": "application/json"]]

这篇关于使用 httpotion elixir 发布到 slack api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆