clj-http 2021-02-11

@ps has joined the channel

I want to make the following curl command in clj-http:

curl  \
  -u sk_test_51HdVtpHywc8Pkve8afG508Ps1vdsLFqhYl0LzAUF1ImwClpPfGsjnQ2t7XNjBYgSZMnRsF9VfU55rGHbFEhICOi200kisYnuJK: \
  -d customer=cus_IvNWjfw1q2clxS \
for which I have the following:
(client/post "" {:basic-auth "sk_test_51HdVtpHywc8Pkve8afG508Ps1vdsLFqhYl0LzAUF1ImwClpPfGsjnQ2t7XNjBYgSZMnRsF9VfU55rGHbFEhICOi200kisYnuJK:" :form-parms {:customer cus_IvNWjfw1q2clxS}})
but this isn’t working, suggesting that -d corresponds to some other key. I couldn’t find which key instead of form-params would work in the docs. Your help will be appreciated. Thanks

Reading your code, I think there's a typo in :form-params , I see :form-parms

@rymndhng correcting the typo doesn’t work either. The -d params aren’t going through with form-params

do you have ring/ring-codec , try that with {:as :x-www-form-urlencoded}

@rymndhng how to use ring/ring-codec in this case?

just adding

{:as :x-www-form-urlencoded}
didn’t work

@seancorfield has joined the channel

@ps Hmm, I wrote a small test here to show that :form-params is encoded properly by saving the request:

(slurp (.getContent (:body (:request (clj-http.client/post "" {:form-params {:foo "bar"} :save-request true})))))
"foo=bar"
You could use something similar to confirm what's being sent in the body. Also, as some of the other folks have mentioned in #clojure, your credentials are exposed in the logs, and you should rotate those credentials

@rymndhng At least this channel wasn't being logged -- but I am going to add the log bots now: I just didn't know this channel even existed!

😁 1

@logbot has joined the channel

@rymndhng there’s a difference between the curl -f tag and the -d tag. I think form-params is associated with -f, and there’s something else for -d. I know that stripe isn’t getting the request as it’s supposed to based on the returned map

@iammiles has joined the channel

@vincent.sampieri5 has joined the channel