public HttpResponseMessage Post([FromBody] EntityModel value) { try { bool isSuccess = SourceData.CreateEntity(value); if (isSuccess) { var message = Request.CreateResponse(HttpStatusCode.Created, value); message.Headers.Location = new Uri(Request.RequestUri + value.id.ToString()); return(message); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "No entity was created")); } } catch (Exception ex) { Logger.Fatal("createEntity function in EntityController" + ex.InnerException); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.InnerException.ToString())); } }