This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
I'm trying to translate a curl
call into Clojure, using clj-http
Using the right subdomain, email, and token, this works:
'''
curl -X POST 'https://my-sub-domain.slack.com/api/users.admin.invite' \
--data '[email protected]&token=supersecretoken&set_active=true' \
--compressed
`
It invites a user,
, using my token, supersecretoken
Which is kind of cool
Sadly, though, this does not work:
(require '[clj-http.client :as http])
(require '[clojure.data.json :as json])
(http/post ""
{:body
(json/json-str
{"json"
{:email ""
:token "supersecretoken"
:set_active true}})
:body-encoding "UTF-8"
:content-type :json
:accept :json})
I get a response which tells me I didn't include a token in my request.
With curl you are sending the data using form encoding and in clojure code you are enconding it using json. In a very quick view, this is a thing that can stay wrong
Hmm...fair point, though it seems it should be possible to translate the HTTP call to Clojure...
Ah, I found it
(http/post ""
{:multipart
[{:name "email" :content ""}
{:name "token" :content "supersecretoken"}
{:name "set_active" :content "true"}]})
@niwinz: I bet you're right that there is a way to use form-params
as well
You are right, this works also:
(http/post ""
{:form-params
{:email ""
:token "supersecretoken"
:set_active "true"}})
Good to learn more about how to use this - thanks for your help!