What response pattern in a file does an action partially perform?

2

#define API http://localhost:80/api/v1/resources.  When doing a POST in resources , the user (dev) can register / include an N number of resources.  Assuming some (uns) record could not be entered, but the rest was successfully. How could the response be? What status? 200 ok, 201, another? Which standard should be followed?

    
asked by anonymous 28.11.2016 / 21:00

1 answer

4

In similar situations I use the following pattern:

  • 200 : OK
    No errors found.

  • 202 : Accepted
    Success when sending payload. is not considered an error status; return a payload containing the individual success or error descriptors.

  • 40* : Bad Request / Unauthorized / Forbidden / Not Found / etc.
    Validation errors.

  • 500 : Internal Server Error
    The application threw an exception.

  • Optional - 207 : Multi-Status ( WebDAV ) > If your client supports WebDAV or XML, respond with a payload multi-status , indicating the results of each operation. The RFC that defines 207 / Multi-Status sets XML as the desired format, which can prevent its implementation on REST / Json-based clients.

28.11.2016 / 22:04