A developer is working with VS 2022 and C#.NET 9 to implement an API. When making a PUT request from Scalar, the breakpoint is hit and the update is processed, but an error message is received stating:
"failed to construct 'response' response with null body status cannot have body"
The API is designed to return NoContent(), but instead of receiving a 204 status code, the error message appears.
What steps can be taken to resolve this issue?
[HttpPut("{id}")]
public async Task<IActionResult> UpdateVidoeGame(int id, VideoGame updatedGame)
{
var game = await _context.VideoGames.FindAsync(id);
if (game is null)
return NotFound();
game.Title = updatedGame.Title;
game.Platform = updatedGame.Platform;
game.Developer = updatedGame.Developer;
game.Publisher = updatedGame.Publisher;
await _context.SaveChangesAsync();
return NoContent();
}