Search code examples
kotlinandroid-volleydynamics-365dynamics-business-central

Limit the number of records fetched through API call in Business Central


Scenario:


Hi,

I'm fetching some data from business central API in Kotlin using volley library, but the problem is, the JSON response has about 20000 values or records and the size of JSON is about 12MBs and it takes way to much time and resource to get and manipulate that much data.

Question:


So, is there a way to limit, how many number of items, values, rows or records what ever you say it? Like probably in Business Central.

Explanation:


Like that there are about 20000 of such records and I want to limit them to a specific number.

I probably don't have to mention about the library I used to fetch data 'cause I think it would be solved through Business central but still just in case I did.

"value": [
        {
            "id": "00000000-0000-0000-0000-000000000000",
            "number": "",
            "displayName": "",
            "type": "",
            "itemCategoryId": "00000000-0000-0000-0000-000000000000",
            "itemCategoryCode": "",
            "blocked": false,
            "gtin": "",
            "inventory": 0,
            "unitPrice": 0,
            "priceIncludesTax": false,
            "unitCost": 0,
            "taxGroupId": "00000000-0000-0000-0000-000000000000",
            "taxGroupCode": "",
            "baseUnitOfMeasureId": "",
            "baseUnitOfMeasureCode": "",
            "lastModifiedDateTime": ""
        },
        {},
        {},
        {},
        {},
        {},
        {}, 
        ............. upto to so on.

Thanks in Advance.


Solution

  • To set paging on a request, use the odata.maxpagesize preference in the Prefer header of the HTTP request:

    Prefer: odata.maxpagesize=300
    

    See MS Docs - Server-Driven Paging in OData Web Services.