credentials_dev_public icon indicating copy to clipboard operation
credentials_dev_public copied to clipboard

[API] DELETE endpoints respond differently

Open AndreSchwarzer opened this issue 2 years ago • 3 comments

The Issue I encountered

When deleting resources I expect the same/similar responses from the API.

  • Deleting an existing person results currently in a 200 response with a JSON body.
  • Deleting an non existing person results currently in a 404 response with a JSON body.
  • Deleting an existing document results currently in a 200 response with a text body.
  • Deleting an non existing document results currently in a 200 response with a text body.

I would expect a 204 No Content for a successful deletion and a 404 Not Found, maybe with further details in a JSON body, as a response.

In case 200 OK is the desired status for this project, the response should, in IMHO, be always a JSON in the same schema.

How to reproduce the description above

Delete a person by id /v1/delete_person

Resource exists

Call

curl -X 'DELETE' \
  'https://sandbox.api.credentials.dev/v1/people/34a36028-dddc-477f-9676-ceb75089658a/' \
  -H 'accept: application/json' \
  -H 'X-API-Key: REDACTED'

Response

Code: 200 Body:

{
  "deleted": true
}

Resource doesn't exists (anymore)

Call

curl -X 'DELETE' \
  'https://sandbox.api.credentials.dev/v1/people/34a36028-dddc-477f-9676-ceb75089658a/' \
  -H 'accept: application/json' \
  -H 'X-API-Key: REDACTED'

Response

Code: 404 Body:

{
  "detail": "Could not find this person for this tenant."
}

Delete a document by id /v1/people/{person_id}/documents/{document_id}/

Resource exists

Call

curl -X 'DELETE' \
  'https://sandbox.api.credentials.dev/v1/people/34a36028-dddc-477f-9676-ceb75089658a/documents/c2141f12-8d69-47d1-8ea5-779496a8ac53/' \
  -H 'accept: application/json' \
  -H 'X-API-Key: REDACTED'

Response

Code: 200 Body:

true

Resource doesn't exists (anymore)

Call

curl -X 'DELETE' \
  'https://sandbox.api.credentials.dev/v1/people/34a36028-dddc-477f-9676-ceb75089658a/documents/c2141f12-8d69-47d1-8ea5-779496a8ac53/' \
  -H 'accept: application/json' \
  -H 'X-API-Key: REDACTED'

Response

Code: 200 Body:

false

AndreSchwarzer avatar Dec 27 '22 13:12 AndreSchwarzer