I have an OData service endpoint built with CAP Java that returns an array of objects. And because there is special data handling (filter for the last day/hour) the data is returned by a function. However, a consumer of this endpoint (SAC) is having problem because it requires $count for the returned array, which is absent in the response (no @count or @nextLink fields). Therefore, the question is whether it is possible to add @count and @nextLink into a response returned by a function in CAP Java?
I simulates the query from the tool: https://myhost/odata/v4/MonitoringService/dailyTaskCreateCommandsWithLifeCycles()?$count=true
And I got this error response
{
"error": {
"code": "50008010",
"message": "The query result misses a value for $count"
}
}
200 response of this endpoint https://myhost/odata/v4/MonitoringService/dailyTaskCreateCommandsWithLifeCycles() as follows:
{
"@context": "$metadata#Collection(MonitoringService.CommandsWithoutUserData)",
"@metadataEtag": "W/\"201af60104910da2489334b66e32c04a659f06f4125792608fe944d308336a79\"",
"value": [
{
"ID": "aa5bc5f5-f8be-441f-bc81-a7ed353c1559",
"dataType": "commandRequest",
"runId": "aa5bc5f5-f8be-441f-bc81-a7ed353c1559",
"runtimeId": "orch",
"transformationAreaId": "df0bdb10-e275-4af2-bfa1-53fe847398be",
"version": "1.0.0",
"eventType": null,
"policy": null,
"topic": null,
"webhook": null,
"lifeCycle": 1,
"status": "finished",
"createdAt": "2024-03-07T14:06:16.468843Z",
"modifiedAt": "2024-03-07T14:09:28.697783600Z",
"startTime": "2024-03-07T14:06:16Z",
"endTime": "2024-03-07T14:09:28Z",
"useCase": null
},
{
"ID": "4e7b4318-adbe-4720-8fbd-cc6d830011c6",
"dataType": "commandRequest",
"runId": "4e7b4318-adbe-4720-8fbd-cc6d830011c6",
"runtimeId": "orch",
"transformationAreaId": "d9273be7-9f76-4355-8fd9-e108a7fe7dca",
"version": "1.0.0",
"eventType": null,
"policy": null,
"topic": null,
"webhook": null,
"lifeCycle": 1,
"status": "finished",
"createdAt": "2024-03-07T13:56:13.947212300Z",
"modifiedAt": "2024-03-07T14:13:47.126574800Z",
"startTime": "2024-03-07T13:56:13Z",
"endTime": "2024-03-07T14:13:47Z",
"useCase": null
}
}