Epicor REST Pagination

Hello,

I have a question regarding the Epicor REST API. I am currently trying to retrieve all Job Entries for a specific company.
I am using the following URL: https://BaseCompanyURL.com/EpicorERP/api/v1/Erp.BO.JobEntrySvc/JobEntries?$filter=Company eq ‘123’.
This works fine except for the fact that it only returns the first 100 records. In order to work around this, I am using the $Skip and $Top conditions to keep pulling the next 100 records until there are no more records to retrieve. This means using multiple successive REST calls to retrieve the entire data set. The problem with this is that every successive REST call takes longer than the preceding one, eventually causing each call to take upwards of 10 seconds. The reason behind this is due to the $Skip condition, which slows down the query the larger the skip requirement gets.

Any recommendations on what I can do to pull all the records in a reasonable amount of time?

Hi Jason,

When I’m just reading, I use the BAQ service. It pulls all records, you can pass parameters in the URL, it’s resistant to most changes.

Mark W.

2 Likes

BTW, unlike a dashboard, the BAQ won’t know that there is a dependency by a REST client. I’m working on a naming convention that indicates that this BAQ was written for REST consumption and including some kind of version number for breaking changes.

Mark W.

The skip and top map to the GetList/ GetRows approach in WCF - basically sending in a page count to a stored proc doing a ‘RowNumber() Over’ approach in the sproc:

SELECT *, SortOrder = Row_Number() OVER (ORDER BY [t2].[Company], [t2].[MfgSys], [t2].[TipNum])

Take a peak at any of the sprocs in the db and you’ll see what I mean - I am willing to chat about the design if anyone wants to uber geek on sproc approaches :wink:

The point is that the queries are only pulling back 100 records at a time (default) or whatever the admin sets in the web.config for ‘max records per call’ →

<appSettings>
<add key=“DefaultMaxRowCount” value=“<number or 0 to remove the limit>” />

If you change that, you are changing ALL calls limits so be careful that you don’t overwhelm your server.

If you are seeing progressively slower responses, I’d look a little deeper. It should not be coming from the REST calls or please open a ticket, that’s not correct.

1 Like

I do the same.

1 Like

Thanks for the help. I work with Jason, the original poster.
Changing that setting worked, however it does not seem like a great idea in the long run. I was wondering, is there way to query for the count of all the records? Once I have the count then I can use the $top condition to specify exactly how many records I need. I know this is supported in some odata implementations, however I cannot seem to get it to work with Epicor.

There is no ‘Count’ record in the core of ERP so REST didn’t have anything to connect to and provide one.

FYI - For the WCF services, we query for records 1 - 101 records, show the first 100 and if there is 101 records, we know we have a second page. If a second page, we query for 101 - 201 and show records 101 to 200 (100 records) and indicate a third page, etc. It works very well to provide both a limited chunk of records at a time to minimize sever impact and provides a decent UX.

2 Likes

Ok sounds good. Thanks again Bart for all your help, much appreciated!

Hi, I know this is an old post but how did you get around this? Was it using a baq, thanks in advance

Hey brychan,

Yes, we did just work around this by just using a BAQ rather than the BO methods in many cases. Hope this helps.

Hi Jason, thanks for the quick response. From previous experience , the rest APIs are good for transactional stuff but not for heavy lifting. Out of interest what version are you running? Again , thanks

We’re currently running on Epicor 10.2.600.