Is there a way I can add a message to a BadRequest
action result, and for that message to be visible to external clients, such as Postman? I am using ASP.NET Core 3.1.
Part of my code is included below. I want to say what the problem is—e.g., that the id
sent in the body is not the same as the one taken from the URL. For now, I am using an Error
object that I’ve made, which has the error code and message. But those aren't visible in Postman when I send the request.
public ActionResult PutColour(int id, Colour colour)
{
if (id != colour.Id)
{
return BadRequest(new Error("IDNotTheSame","ID from URL is not the same as in the body."));
}
}