Closed nottmey closed 7 years ago
All POST bodies have to be under the "payload" key. The purpose is to minimize key clashing where a body gets posted to various systems. It also allows you to transact multiple entities with a single POST. This may be changed in future versions of Vase, but it's generally useful to have uniform handling of single/multiple transactions across all POST endpoints.
Try the following cURL command:
curl -H "Content-Type: application/json" -X POST -d '{"payload": [{"user/userId":"42","user/email":"user@example.com"}]}'
curl -H "Content-Type: application/json" -X POST -d '{"payload": [{"user/userId":"42","user/email":"user@example.com"}]}' http://localhost:8080/api/accounts/v1/user
resulted in
e | a | v | added |
---|---|---|---|
13194139534323 | :db/txInstant | #inst "2017-02-04T13:08:41.859-00:00" | true |
17592186045428 | :user/userId | 42 | true |
17592186045428 | :user/email | user@example.com | true |
with the response
{"whitelist":[{"user/userId":"42","user/email":"user@example.com"}],"transaction":[[null,null,null],[null,null,null],[null,null,null],[null,null,null]]}
So using the payload wrapper works. Thank you! (Also solves a question about bulk adding. Tested multiple entities and it worked. Wrapping and Bulk adding is missing in the tutorial right now.)
Thanks for reaching out with the issue!
Form data isn't supported by the transact
action literal at this time (it only pulls data out of JSON payloads). At one point, Vase transact
did support form data, but we've mainly used Vase JSON-based microservices, where every client was talking JSON (and in some cases, Transit).
I'm going to leave this issue open to address two main things:
transact
response is fetching/selecting data that doesn't exist (I assume this is because the latest Datomic release changed how string-keys were passed into transactions, and that affects how Vase was normalizing them)I will fix the docs.
Master now has the transact
fix -- you'll see EAV vectors of the successful transaction.
Thanks @mtnygard for doc updates!
Description
I followed the Tutorial "Building your first API" to "Getting data in with transact", but I can't get
:post
to be transacting the new entity. It boils down to the following problem.My minimal EDN:
Request-Variations: (same response)
Response:
Log: (for one request)
Datomic: (checked with datomic console, schema is applied, only the transaction is created)
13194139534317 :db/txInstant #inst "2017-02-04T09:50:22.443-00:00" true
Environment
OS: Mac El Captain - 10.11.6 JVM: jdk1.8.0_74 Leiningen: 2.7.1 Clojure: 1.9.0-alpha14 Pedestal: 0.5.2 Vase: 0.9.0
Datomic Transactor: datomic-free-0.9.5544
(generated on 3. Feb. with
lein new vase anytitle
)