public HttpResponseMessage Post([FromBody] Pacient pacient) { try { using (PacientContext ctx = new PacientContext()) { Pacient newPacient = _pacientService.AddPacient(pacient); //return 201 Created var msg = Request.CreateResponse(HttpStatusCode.Created, pacient); //included location msg.Headers.Location = new Uri(Request.RequestUri + pacient.PacientId.ToString()); return(msg); } }catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e)); } }