-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Pagination does not work when calling GetListAsync on Contract-Based API entities.
Even when $skip and $top are specified, all records are returned.
This appears to be caused by the caller method not forwarding the pagination parameters to ComposeQueryParams.
Example:
EntityAPI_Implementation.cs
protected async Task<ApiResponse<List<EntityType>>> GetListAsyncWithHttpInfo(
string select = null, string filter = null, string expand = null, string custom = null,
int? skip = null, int? top = null, Dictionary<string, string> customHeaders = null)
{
HttpResponseMessage localVarResponse = await ApiClient.CallApiAsync(
$"{GetEndpointPath()}/{GetEntityName()}",
HttpMethod.Get,
ComposeQueryParams(select, filter, expand, custom), // <- CALLER
null,
HeaderContentType.Json,
HeaderContentType.None,
customHeaders);
VerifyResponse(localVarResponse, "GetList");
return DeserializeResponse<List<EntityType>>(localVarResponse);
}
Although the method accepts skip and top, these parameters are not passed to ComposeQueryParams, so they never reach the request.
Expected Behavior
When skip and top are provided, the generated request should include:
-
$skip
-
$top
and the API should return only the requested page of records.
Actual Behavior
-
$skip and $top are omitted from the request
-
The API returns all records
-
Client-side pagination loops never terminate
Supporting Evidence
From Acumatica.RESTClient.Api → BaseApi.cs, pagination is clearly supported:
protected List<KeyValuePair<string, string>> ComposeQueryParams(string select = null, string filter = null, string expand = null, string custom = null, int? skip = null, int? top = null)
{
var queryParameters = new List<KeyValuePair<string, string>>();
if (!String.IsNullOrEmpty(select)) queryParameters.AddRange(ApiClient.ParameterToKeyValuePairs("", "$select", select)); // query parameter
if (!String.IsNullOrEmpty(filter)) queryParameters.AddRange(ApiClient.ParameterToKeyValuePairs("", "$filter", filter)); // query parameter
if (!String.IsNullOrEmpty(expand)) queryParameters.AddRange(ApiClient.ParameterToKeyValuePairs("", "$expand", expand)); // query parameter
if (!String.IsNullOrEmpty(custom)) queryParameters.AddRange(ApiClient.ParameterToKeyValuePairs("", "$custom", custom)); // query parameter
if (skip != null) queryParameters.AddRange(ApiClient.ParameterToKeyValuePairs("", "$skip", skip)); // query parameter
if (top != null) queryParameters.AddRange(ApiClient.ParameterToKeyValuePairs("", "$top", top)); // query parameter
return queryParameters;
}
Suggested Fix
Update the caller to pass skip and top:
ComposeQueryParams(select, filter, expand, custom, skip, top)