Home > database >  Rest API: HTTP Status code for Informational Message
Rest API: HTTP Status code for Informational Message

Time:05-07

If end user not send query parameter then i want to return a message like:

return Response.status(500).entity("If you wish to download whole offerings data send query Param 'timestampForInitialLoad'. If you wish to get offerings after particular date then send query Param as 'lastModifedDate'").build();

What will be HTTP Status code for such message?

Will it be 500 Internal Server Error (well it is not)

or will it be 204 No Content (But content is message itself)

or will it be 200 Success (But call is not correct)

Not able to get from 1XX HTTP Status codes

CodePudding user response:

I would say it should be 400 bad request, because you expect the request to have that query parameter.

CodePudding user response:

What will be HTTP Status code for such message?

404 Not Found would be the usual answer.

4xx, because you are trying to call the client's attention to a problem in the HTTP request (not the handling of the request), and clarifying for general purpose HTTP components that the response body is a representation of an explanation of the error situation (not a representation of the resource).

404, because you are specifically calling attention to the target URI of the HTTP request. 404 also has the advantage that it is heuristically cacheable.

  • Related