I am trying to use Eve to provide a RESTful API for a simple list of items.
I would like to use 1) one HTTP request to create a list (possibly with initial elements), 2) one HTTP request to add element (s) (general operation), 3) one HTTP request to get a list (including all child elements). In other words:
1) POST /lists with body
{ "title": "My List", "items": [{ "name": "Alice" }, { "name": "Bob" }] }
2) POST /lists/555555555555555555555555/items with body
{ "name": "Carol" }
3) GET /lists/555555555555555555555555
{ "_id": "555555555555555555555555", "title": "My List", "items": [{ "_id": "aaaaaaaaaaaaaaaaaaaaaaaa", "name": "Alice" }, { "_id": "bbbbbbbbbbbbbbbbbbbbbbbb", "name": "Bob" }, { "_id": "cccccccccccccccccccccccc", "name": "Carol" }] }
I did not understand how to do this with Eve. I can do (1) using the built-in dicts list, but then I can not do (2) - I needed to send a POST element, and then a PATCH list ( ? ). I can do (2) using sub-resources, but then I can not do (1) ( "value '{'name': 'Alice'}' cannot be converted to a ObjectId" ). Or am I missing something?
If all three cannot be fulfilled, perhaps at least (2) and (3)?
source share