Fork me on GitHub
#clj-http
<
2022-03-02
>
zendevil.eth14:03:08

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

zendevil.eth14:03:24

This doesn’t seem to work:

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

jumar16:03:29

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

zendevil.eth19:03:30

but we have body-params in the server

zendevil.eth19:03:34

we need body-params

jumar20:03:51

: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.

jumar20:03:40

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.eth20:03:24

: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

jumar20:03:30

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