clj-http

zendevil.eth 2022-03-02T14:57:08.606169Z

how do you send body-params in a clj-http.client/post request?

zendevil.eth 2022-03-02T14:57:24.822329Z

This doesn’t seem to work:

(clj-http.client/post "" {:body {:email ""
                                                              :password "password"}
                                                })

jumar 2022-03-02T16:18:29.406549Z

It's typically send within :form-paramshttps://github.com/dakrone/clj-http#post

zendevil.eth 2022-03-02T19:14:30.297899Z

but we have body-params in the server

zendevil.eth 2022-03-02T19:14:34.765439Z

we need body-params

jumar 2022-03-02T20:08:51.141599Z

:form-params is a standard way to do it. You will find them in :form-params in the ring request as well as :body-params.

jumar 2022-03-02T20:10:40.439329Z

You can see how this gets converted to request body here: https://github.com/dakrone/clj-http/blob/3.x/src/clj_http/client.clj#L951

zendevil.eth 2022-03-02T20:13:24.247609Z

:form-params definitely doesn’t work if you have the following in your reitit handler:

["/api/login" {:coercion spec/coercion
                  :post login-handler
                  :parameters {:body ::login-params}
                  }
you get a 400

jumar 2022-03-02T20:28:30.330769Z

Well, then it's specific to reitit or you are sending wrong params. Can you share the whole thing?

zendevil.eth 2022-03-02T20:36:33.087289Z

https://github.com/zendevil/coercion-poc