I use httpkit as http client. I try many solutions to make the header Content-Type
be application/json
, but all failed.
Here is my code:
(require '[org.httpkit.client :as http])
(http/post
url
{ :query-params {"q" "foo, bar"}
:form-params {"q" "foo, bar"}
:headers {"Content-Type" "application/json; charset=utf-8"}})
Post with the code above would get response status 200
but Content-Type
is application/x-www-form-urlencoded
.
And if delete the line application/x-www-form-urlencoded
, would get response status 400
.
PS: I take flask as web server.
I haven't used httpkit
(can recommend clj-http
) but I think you should use the :body
option instead of :form-params
to specify payload as the latter would force the Content-Type
to application/x-www-form-urlencoded
. It makes sense considering how form params work in HTTP.