- Olivier PAVLIN
- SnapDevelop
- Wednesday, 20 November 2019 03:20 PM UTC
Hi there,
In my MVC .Net Web API i have this auto-generated GET function in my controller which works fine and return the list of all the elements in my table (SimpleJson.png).
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<Ds_Invit_Sydrtcml>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult<IEnumerable<Ds_Invit_Sydrtcml>> Get()
{
var modelList = _ids_invit_sydrtcmlservice.Retrieve();
if (modelList.Count() == 0)
{
return NotFound();
}
return new ActionResult<IEnumerable<Ds_Invit_Sydrtcml>>(modelList);
}
But i would like to add more infos ("count", "duration", "success"...) in the JSON response and embed the current result in a "data" [ ... ] container to be compliant with this format :
{ "count": 10, "data": [ { "label": null, "machineId": "TEST", "uuid": "38d17263-cfdd-4d91-97c6-e1938012c4f8" }, { "label": "Laveuse 01", "machineId": "LAV01", "uuid": "DEMO_MACH_WS01_PL01_CL04_LAV01" } ... etc... ], "duration": "125.860", "meta": { "offset": 0, "size": 1000, "total": 10 }, "size": 3728, "success": true, "total": 10 }
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.