[RequestHeaderMatchesMediaType("Content-type", new[] { "application/vnd.mike.author.full+json" })] //with versioning media types public IActionResult CreateAuthor([FromBody] AuthorForCreationDto author) { if (author == null) { return(BadRequest()); } var authorEntity = author.ConvertToAuthorEntity(); _libraryRepository.AddAuthor(authorEntity); if (!_libraryRepository.Save()) { throw new Exception(); //with global exception handling, we can throw exception //return StatusCode(500, "problem"); } var authorToReturn = authorEntity.ConvertToAuthorDto(); var links = CreateLinksForAuthor(authorToReturn.Id, null); //add links to post author, convert authordto to expandoobject var linkedResourceToReturn = authorToReturn.ShapeData() as IDictionary <string, object>; linkedResourceToReturn.Add("links", links); //need a name on the get method call to use it here //return CreatedAtRoute("GetAuthor", new { id = authorToReturn.Id }, authorToReturn); //with links return(CreatedAtRoute("GetAuthor", new { id = linkedResourceToReturn["Id"] }, linkedResourceToReturn)); }