You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I set up a sample project, by doing copy and paste from the sweet-liberty-example.
The GET works fine, now I'm trying to implement the POST.
It also works fine when I use URL-encoded form params in the body, but I prefer to send a JSON.
So I set the Content-Type to application/json, and put a json (which looks the same like the one I receive from the GET) in the body.
Then I get a stacktrace with an empty INSERT statement:
INSERT INTO CustomDocumentTemplateEntity ( ) VALUES ( )
Looking into the handlers.clj of sweet-liberty, I see this:
(defnmake-create-entity-fn"Create a function that creates a new entity in storage and returns the new primary key value on the ctx at ::post-id."
[table db-spec name-transforms input-transform _ conditions]
(fn [{{form-params :form-params body-params :body-params} :request:as ctx}]
(let [data (keywordize-keys (or body-params form-params))
So I assume for that to work, the data must be either in the :form-params or in the :body-params field of the request.
I'm using ring.middleware.json/wrap-json-body, which packs the data into :body (but not into :body-params), which in my opinion is correct.
Should the code maybe be like this instead? (Haven't tested it yet, only a suggestion)
Hi,
I set up a sample project, by doing copy and paste from the sweet-liberty-example.
The GET works fine, now I'm trying to implement the POST.
It also works fine when I use URL-encoded form params in the body, but I prefer to send a JSON.
So I set the Content-Type to application/json, and put a json (which looks the same like the one I receive from the GET) in the body.
Then I get a stacktrace with an empty INSERT statement:
INSERT INTO CustomDocumentTemplateEntity ( ) VALUES ( )
Looking into the handlers.clj of sweet-liberty, I see this:
So I assume for that to work, the data must be either in the :form-params or in the :body-params field of the request.
I'm using
ring.middleware.json/wrap-json-body
, which packs the data into :body (but not into :body-params), which in my opinion is correct.Should the code maybe be like this instead? (Haven't tested it yet, only a suggestion)
Or do I miss something in the setup that re-wraps the json into body-params? I made sure I added wrap-params, but don't think it would help here?
The text was updated successfully, but these errors were encountered: