-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
On making a POST request to a CRUD endpoint, the response is something like:
[{'id': 4}]
IMHO this should be a dict following good REST practices and not a list since we cannot post multiple objects to the CRUD Endpoint. The client should be able to run something like:
>>> response = requests.post(crud_endpoint_url, json=data).json()
>>> response['id']
# created object id
The problem stems from this line: https://github.com/piccolo-orm/piccolo_api/blob/master/piccolo_api/crud/endpoints.py#L819
Actually row.save().run() seems to always return a list with one object ... assuming this is the case, we could strip the object out of the list and simply return the dict:
response = await row.save().run()
item = response[0]
json = dump_json(item)
return CustomJSONResponse(json, status_code=201)
mastercoms
Metadata
Metadata
Assignees
Labels
No labels