I am building a REST API using .net WEB API.
What is the best/recommended response for expected errors?
Situation: There is plane with places.The place can be booked by another person. If reservation was failed by expected error, what the response I need to create ? Now, I use this:
[Route("{number}/reservation"), HttpPost]
public IHttpActionResult Reservation(string number)
{           
  if (string.IsNullOrEmpty(number))
    return Content(HttpStatusCode.BadRequest, "Number required");
  var result = Reservation(number);
  if (result.IsValid)
  {
     return Request.CreateResponse(HttpStatusCode.OK);
  }
  else
     return Request.CreateResponse(HttpStatusCode.OK,result.ErrorMessage);
}
 
    