Share via

Issue with PUT API Call Returning Null Body Status

Timothy Gregory 20 Reputation points
2025-05-28T23:40:18.1266667+00:00

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();

    }
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


Answer accepted by question author

Bruce (SqlWork.com) 84,071 Reputation points
2025-05-29T15:57:40.5333333+00:00

this sounds like an issue with scalar. You probable have to add metadata to define the valid response codes. Probably defaults to 200. As scalar is an open source project, you will need to review its docs on how this is done.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.