clj-http

zendevil 2021-02-11T04:37:09.002500Z

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

curl <https://api.stripe.com/v1/subscriptions> \
  -u sk_test_51HdVtpHywc8Pkve8afG508Ps1vdsLFqhYl0LzAUF1ImwClpPfGsjnQ2t7XNjBYgSZMnRsF9VfU55rGHbFEhICOi200kisYnuJK: \
  -d customer=cus_IvNWjfw1q2clxS \
for which I have the following:
(client/post "<https://api.stripe.com/v1/customers>" {: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

2021-02-11T04:43:16.003100Z

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

zendevil 2021-02-11T04:49:37.004100Z

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

2021-02-11T04:58:23.004800Z

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

zendevil 2021-02-11T04:58:48.005100Z

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

zendevil 2021-02-11T05:00:55.005500Z

just adding

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

2021-02-11T05:14:13.008400Z

@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 "<http://example.com>" {: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

seancorfield 2021-02-11T05:17:13.009400Z

@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
zendevil 2021-02-11T06:02:05.011400Z

@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