-2

Description:

The user inquires about the availability of the event on a given day.

Question: Which response code should I send back if new event can not be created on this day? 404? 400? 422?

My choice: I chose the "404 Not Found" status code:

{
  "statusCode": 404,
  "error": "Not Found",
  "message": "The event can not be created on the selected date."
}
Adee
  • 357
  • 1
  • 3
  • 13
  • You say "inquire" and then your message says "create". Which is it? – Jonathon Reinhart Jun 01 '19 at 21:03
  • I just want to check if the event is available on a given day or is not available. If it is not available, I want to send back the error. However, I do not know what the status code should I use. – Adee Jun 01 '19 at 21:07

2 Answers2

0

As a response to a POST request I would use the 422 Unprocessable Entity status code along with a description of why the request could not be processed.

If you only want to test if there is already an event at this day, perform a GET request (for example: /event/2019-06-01) to check if it exists. If it does not exist yet, respond with a 404 not found.

nr1chiefrocka
  • 134
  • 1
  • 7
-1

Your question is entirely opinion based. You should try learning about various status codes and their reasons. In your case, you may find status code 410 useful, but again, this is entirely opinion based.

JJ.
  • 112
  • 2
  • 10