// POST: api/links // Input example: { "Title": "Products", "URL": "http://pr.com", "Cathegory": "Electronics"} public HttpResponseMessage PostLinkToDB([FromBody] Link link) { HttpResponseMessage response = null; if (ModelState.IsValid) { try { var addedLink = service.AddLink(link); response = Request.CreateResponse( HttpStatusCode.Created, addedLink); string uri = Url.Link("DefaultApi", new { id = addedLink.LinkID }); response.Headers.Location = new Uri(uri); return(response); } catch (Exception ex) { Trace.TraceError(ex.Message, ex); response = Request.CreateResponse <string>(HttpStatusCode.InternalServerError, ex.Message); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } return(PrepareResponse(HttpStatusCode.OK, "Successfully added")); }