I have an API controller endpoint like:
public IHttpActionResult AddItem([FromUri] string name)
{
try
{
// call method
return this.Ok();
}
catch (MyException1 e)
{
return this.NotFound();
}
catch (MyException2 e)
{
return this.Content(HttpStatusCode.Conflict, e.Message);
}
}
This will return a string in the body like "here is your error msg"
, is there any way to return a JSON with 'Content'?
For example,
{
"message": "here is your error msg"
}