HTTP Status Codes für PUT/POST/PATCH/DELETE-Requests
Aktuell werden in einigen Endpunkten fälschlicherweise die Status Codes 201 Created
und 200 OK
verwendet. Es ist für jeden Endpunkt zu prüfen, ob die Status-Codes konform zu RFC 7231 verwendet werden.
Relevante Status-Codes
Code | Beschreibung |
---|---|
200 OK | The request has succeeded. For PUT requests, the response should contain a representation of the status of the action. For POST requests, the response should contain a representation of the status of, or results obtained from, the action. If no payload is desired, an origin server ought to send 204 No Content instead. |
201 Created | The request has been fulfilled and has resulted in one or more new resources being created. The 201 response payload typically describes and links to the resource(s) created. |
202 Accepted | The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. |
204 No Content | The server has successfully fulfilled the request and that there is no additional content to send in the response payload body. |
POST-Request
https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.3 sagt hierzu:
If one or more resources has been created on the origin server as a result of successfully processing a POST request, the origin server SHOULD send a 201 (Created) response containing a Location header field that provides an identifier for the primary resource created (Section 7.1.2) and a representation that describes the status of the request while referring to the new resource(s).
PUT-Requests
https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.4 sagt hierzu:
If the target resource does not have a current representation and the PUT successfully creates one, then the origin server MUST inform the user agent by sending a 201 (Created) response. If the target resource does have a current representation and that representation is successfully modified in accordance with the state of the enclosed representation, then the origin server MUST send either a 200 (OK) or a 204 (No Content) response to indicate successful completion of the request.
DELETE-Request
https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.5 sagt hierzu:
If a DELETE method is successfully applied, the origin server SHOULD send a 202 (Accepted) status code if the action will likely succeed but has not yet been enacted, a 204 (No Content) status code if the action has been enacted and no further information is to be supplied, or a 200 (OK) status code if the action has been enacted and the response message includes a representation describing the status.
-
DELETE /destinations/{destinationId}
-> 204 -
PUT /submissions/{submissionId}/attachments/{attachmentId}
-> 204 -
POST /submissions/{submissionId}/events
-> 204