In my ASP.NET Core 5 Web API controller, I have this code:
[HttpGet("GetByUID/{uid:int}")]
public async Task<ActionResult<PTHeading>> GetPTHeading(int uid)
{
APIEntityResponse<PTHeading> getResponse = new();
var getResult = await _controller.GetByValue("UID_PTHEADING", uid.ToString());
if (getResult is null)
{
return StatusCode(StatusCodes.Status500InternalServerError,
$"Error retrieving {m_sControllerName} data from the database.");
}
else
{
return Ok(getResult.Result);
}
}
That yields the following result in SWAGGER:
{
"value": {
"isSuccess": true,
"errorMessages": [],
"data": {
"uiD_PTHEADING": 14,
"uiD_CUSTOMER": 17,
"txT_PTHEADING_NAME": "Exterior",
"booL_IS_ACTIVE": true,
"inT_SORT_ORDER": 1
}
},
"formatters": [],
"contentTypes": [],
"declaredType": null,
"statusCode": 200
}
This is not what I need to be returned. I need only this section to be returned...
{
"isSuccess": true,
"errorMessages": [],
"data": {
"uiD_PTHEADING": 14,
"uiD_CUSTOMER": 17,
"txT_PTHEADING_NAME": "Exterior",
"booL_IS_ACTIVE": true,
"inT_SORT_ORDER": 1
}
}
The getResult.Result value is shown here:
I don't know how to get this as a return value.
Any comments, questions or solutions are welcome. Thanks...John

Based on your current code, the
return Ok(getResult.Result);will treat the value ofgetResult.Result(OkObjectResult) as the response body.You can return the response body with
getResult.Result.Value. Note that you should check the status code first and control the value/action result to be returned.Or you can just return the
getResultdirectly.