I have a very similar setup for the person in this question: How to update list_relation data in Python Eve with a user resource and a friends sub-resource like list.
users = { β¦ 'friends': { 'type': 'list', 'schema': { 'type': 'objectid', 'data_relation': { 'resource': 'users' } } } },
However, when I try to add a new value to my friends list, other values ββin the list are replaced with the new value. How to add one value to the list and keep old values?
GET /users/5522987f893e3902048c55ff { "_updated": "Wed, 15 Apr 2015 17:22:07 GMT", "_created": "Mon, 06 Apr 2015 14:30:23 GMT", "_id": "5522987f893e3902048c55ff", "friends": [ "552e9eb0893e391063045edc" ] } PATCH /users/5522987f893e3902048c55ff {"friends": ["550f288d893e390204b0a5ac"]} RESPONSE: { "_updated": "Wed, 15 Apr 2015 19:38:06 GMT", "_created": "Mon, 06 Apr 2015 14:30:23 GMT", "_status": "OK", "_id": "5522987f893e3902048c55ff" } GET /users/5522987f893e3902048c55ff { "_updated": "Wed, 15 Apr 2015 19:38:06 GMT", "_created": "Mon, 06 Apr 2015 14:30:23 GMT", "_id": "5522987f893e3902048c55ff", "friends": [ "550f288d893e390204b0a5ac" ] }
I also tried PUT, but it also replaces the list with a new value.
EDIT: I just tried using POST.
POST /users/5522987f893e3902048c55ff/friends {"552e9eb0893e391063045edc"} RESPONSE: { "_status": "ERR", "_error": { "message": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.", "code": 404 } }
and
POST /users/5522987f893e3902048c55ff {"friends": ["552e9eb0893e391063045edc"]} RESPONSE: { "_status": "ERR", "_error": { "message": "The method is not allowed for the requested URL.", "code": 405 } }
python rest eve
Amy eubanks
source share