tldr:
(-> (session app)
(request "/test/json"
:request-method :post
:content-type "application/json"
:body (.getBytes "\"hello\"" "UTF-8")))
When peridot generates a request map it will default to application/x-www-form-urlencoded
for the content-type for a :post
request. With the app as specified wrap-params
(which is included by compojure.handler/site
) will attempt to read the :body
in order to parse any form-urlencoded parameters. Then json-post
attempts to read the :body
again. However InputStream
s are designed to be read once, and that causes the exception.
There are basically two ways to solve the issue:
- Remove
compojure.handler/site
. - Add a content type to the request (as done in the tldr)