2

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.

2 Answers2

2

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.

Henk van Boeijen
  • 7,357
  • 6
  • 32
  • 42
0

So, is there a way to limit, how many numbers of records

Yes, there's query option $top=n which is used to restrict the amount of data retrieved from the back-end system.
For example, the query option $top=10 will retrieve the top 10 records from the OData service.

XMehdi01
  • 5,538
  • 2
  • 10
  • 34