jsonhttphttp-status-codeshttp-protocols

HTTP status code for "More user input please?"


I am designing a RESTful API and am using the usual HTTP status codes like 200, 404, 500, etc.

Given the situation where occasionally the API will require additional data. When this event arises it needs to respond with a relevant status code so that the client application can present the relevant user interface.

Example:

  1. User fills in form and hits submit (using AJAX)
  2. Server sends response with some status code to indicate that further information is required which is accompanied with additional user interface.
  3. Additional user interface is displayed
  4. User resubmits form

I have this working with a 200 status code, but I would prefer to use a different status code so that my AJAX handler can detect and handle this scenario automatically.

Are there any relevant status codes or would I need to use a sub status code which is returned as a part of my JSON response?


Solution

  • I would go with a 400 Bad Request, since there is more data needed.

    Alternatively, a 100 Continue could also work.

    Either of those codes indicates that more info is needed.