11.2 REST API Pagination?

Is there no pagination functions in 11.2. skip and top do not page past first limits( default 100) of rows. I have used paginations in other API rest services but at a lost with EPICOR functions.

I would assume you’d need to implement your own pagination in a function by adding parameters similar to skip and top.

Can you share some details about your function?

1 Like

Pagination does generally work depending on the BO what BO are you using.

Also version 2 of the API or V1?

Please don’t ban me :rofl:
forgive me monica GIF

We’ll I did see that but it wouldn’t make sense to pagínate on your own function. I took that as I’m lost in Epicor related things :pleading_face:

You can’t pagínate on your own function unless you yourself so it

The BO is V2 “/{currentCompany}/Erp.BO.PartSvc/Parts(‘{Company}’,‘{PartNum}’)”. After a deeper review I have found Epicor’s implementation is different from other versions when it comes to pagination. Other APIs allows me to limit and page through filtered data. Going forward I will use dynamically defined SQL queries to extract data, convert to JSON and use Epicor APIs to transactionally process the data.

Thanks to everybody who replied.

You do you, but I would use the API.

Have you considered using the DynamicQuery service and use a BAQ?

I would prefer an all API approach but Epicor’s pagination is a stumbling block. When extracting 3 to 4 thousand rows of data without pagination is a long process when compared with(Infor ION API) or using SQL queries( example 750ms for a SQL query to extract 6400 rows from Parts/W UDs limiting columns of course).

Curious, what are you doing?

Can you do any of that processing you need to do on the Epicor side?

1 Like

Bi-directional inventory, pricing, customer info updates between dissimilar systems using pure APIs with non-Epicor dynamic queries(SQL), BTW using Python and Windows Server Task Scheduler.

You can do this Pagination fairly easily (with filters) with BAQ

For example there is a standard query zCustomer01 we all have (Built in) returns customer master

You can ask on the API to return Top 100, Skip 100, $filter and it all behaves as it should

Like this First 100 Customers whose name contains A

https://Domain.TLD/EpicorInstance/api/v2/odata/C001/BaqSvc/zCustomer01/Data?$select=Customer_CustID,Customer_Name&$filter=indexof(Customer_Name,'a') gt 0&$top=100&$skip=0

Second 100 Customers (Skip the first 100) whose name contains A

https://Domain.TLD/EpicorInstance/api/v2/odata/C001/BaqSvc/zCustomer01/Data?$select=Customer_CustID,Customer_Name&$filter=indexof(Customer_Name,'a') gt 0&$top=100&$skip=100

Third 100 Customers (Skip the first 200) whose name contains A

https://Domain.TLD/EpicorInstance/api/v2/odata/C001/BaqSvc/zCustomer01/Data?$select=Customer_CustID,Customer_Name&$filter=indexof(Customer_Name,'a') gt 0&$top=100&$skip=200

Etc

4 Likes

Thanks for the reply, but I was trying not to add anymore BAQs to a system with hundreds of them already. I thought about changing the “DefaultMaxRowCount” but that seems like a poor solution.

Awkward Kenan Thompson GIF by Saturday Night Live

… but
BAQs cost (zero) to the system unless they are run and only consume resources when they are being explicitly run / called. So have XX number of BAQs in the system is generally just fine…

Yes, of course your right and I do understand that they’re no performance penalty when the BAQ is not in use. Maybe I’m just tired of Epicor ERP complaints when it’s just some users un-optimized BAQs causing the problems and not Epicor itself. Still I wish there was a usable pagination feature in pure Epicor API/V2. I would even accept the lousy Apex Connector Framework used by Saleforce where I have to declare the QUERY_PAGINATION_SERVER_DRIVEN capability.

1 Like

What happens when you run the equivalent BAQ from PowerShell?

$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch

$c = Get-Credential
$stopWatch.Start()

Invoke-RestMethod "https://(Server)/(Instance)/api/v1/BaqSvc/(YourBaqName)" -Authentication Basic -Credential $c -outfile "records.txt"

$stopWatch.Stop()
$stopWatch.Elapsed

I had the BAQ limit set to 6000 and included every field in PartTran. It ran in 5.229 seconds, including writing the output to a file.

Here is the function version:

//Epicor Function function-5
  List<PartTran> list = (from t in Db.PartTran select t ).Take(6000).ToList();
  
  output = JsonConvert.SerializeObject(list);
//Call Function Powershell Post V2 API
$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch

$c = Get-Credential
$stopWatch.Start()

$header = @{
'X-API-Key' = 'Your-API-KEY'
}

#Post
Invoke-RestMethod https://(Server)/(Instance)/api/v2/efx/(Company)/DEMO/function-5 -Credential $c -outfile "parttran2.txt" -Method Post -Headers $header

$stopWatch.Stop()
$stopWatch.Elapsed

Mine was 17 seconds, but be aware I’m cloud and my pilot is run on a 486 DX2/66.