POST is an HTTP request method for creating a resource or causing a state change. In REST, it commonly handles operations whose result is not guaranteed to repeat identically. section 1.1.4 section 5.5.1
Choose POST for an update when each execution can produce a distinct server effect. The board-game API updates LastModifiedDate on every save, so repeating the operation is not idempotent; PUT would suit a guaranteed identical result instead. section 5.5.1
A practical POST-based update flow:
- Accept client data through a BoardGameDTO rather than exposing the database entity directly. section 5.5.1
- Find the board game using the submitted identifier and apply valid optional fields such as Name and Year. section 5.5.1
- Set LastModifiedDate, update the entity, save changes asynchronously, and return the resulting data. section 5.5.1
Listing 5.10 BoardGameController’s Post method
[HttpPost(Name = "UpdateBoardGame")]
[ResponseCache(NoStore = true)]
public async Task<RestDTO<BoardGame?>> Post(BoardGameDTO model)
{
var boardgame = await _context.BoardGames
.Where(b => b.Id == model.Id)
.FirstOrDefaultAsync();
if (boardgame != null)
{
if (!string.IsNullOrEmpty(model.Name))
boardgame.Name = model.Name;
if (model.Year.HasValue && model.Year.Value > 0)
boardgame.Year = model.Year.Value;
boardgame.LastModifiedDate = DateTime.Now;
_context.BoardGames.Update(boardgame);
await _context.SaveChangesAsync();
};
return new RestDTO<BoardGame?>()
{
Data = boardgame,
Links = new List<LinkDTO>
{
new LinkDTO(
Url.Action(
null,
"BoardGames",
model,
Request.Scheme)!,
"self",
"POST"),
}
};
}
Inspect the controller method to follow the POST update sequence from lookup through persistence and response construction. section 5.5.1
Updating a board game
A POST request for board game ID 181 can change the name from “Risk!” to “Risk” and the year from 1980 to 1959. The controller then records the modification and saves the updated entity. section 5.5.1













