Reputation: 7307
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: syntax error before: '['
Any ideas?
Upvotes: 2
Views: 543
Reputation: 2813
You're missing headers
key
It should be like this:
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"]]
Upvotes: 2
Reputation: 222198
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"]]
Upvotes: 3