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

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: syntax error before: '['
有任何想法吗?

最佳答案

您在标题列表之前缺少headers:。这应该工作:

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"]]

关于api - 使用httpotion elixir发布到松弛api,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38602879/

10-10 16:16