// POST api/chat/5 public IHttpActionResult Post(int id, [FromBody] MessageBindingModel model) { string userId = User.Identity.GetUserId(); Message message; try { message = ChatsService.AddUserMessage(userId, id, model); } catch (NullReferenceException ex) { return(BadRequest()); } catch (UnauthorizedAccessException ex) { return(Unauthorized()); } return(Ok(message)); }