Fork me on GitHub
#planck
<
2019-02-02
>
henrik07:02:01

I'm trying to adjust settings on ElasticSearch with Planck. ElasticSearch wants a JSON blob on a PUT request. How would I format this appropriately with planck.http/put? This is the curl equivalent:

curl -XPUT '' -d '{… blob …}'

mfikes13:02:03

@henrik If you do the following curl command (specifying JSON content type)

curl -XPUT '' -H "Content-Type: application/json" -d '{:foo 1}'
then the equivalent in Planck would be:
(planck.http/put "" {:content-type "application/json" :body "{foo: 1}"})

mfikes13:02:26

Otherwise, curl is actually sending a content-type of application/x-www-form-urlencoded, and in that case a curl request like

curl -XPUT '' -d 'foo=1'
has the following equivalent in Planck:
(http/put "" {:form-params {:foo 1}})
(But I suspect you really want to work with JSON given your description.)

henrik16:02:52

Cool! I didn't see in the docs that you could set :body explicitly. Thank you!

henrik16:02:33

Actually, my bad, it's in the spec.