Rest User Application Error - Help Needed Part 2

OK Dylan, time to spill the beans. What are you trying to do accomplish - from a business perspective? The REST architecture is about changing state via http. The work should be done at the server and not the client. So maybe there’s some tweaks to your process that will reduce the request to fewer than 100 seconds.

@Mark_Wonsil,

I am pulling all PO’s that have not been invoiced via the rest and exporting them in a csv file. Formatting them to fit the needs of our cardholder and sending them to their file import system to be uploaded and processed.

The end goal of this program was to schedule it to run on a server thus automating the process.

As for what all we can do from a logic standpoint on the baq I’m trying to reduce the number of tables it touches.

How long does the BAQ run when run within Epicor?

@Mark_Wonsil
Anywhere from 18k-180k ms depending on how many have yet to process out.

18 seconds seems long let alone 3 minutes. Maybe we can cut that down a bit.

If not, it sounds better to run as a task and then retrieve the results by REST once ready.

Oh I’m guessing its just timing you, pass in a top clause and a next (basically paginate the request)

RestSharp is using HttpWebRequest under the hood, which has a default timeout of 100 seconds.

So that’s why it’s dying near or around a minute and change…
Let me see if I can expose the timeout for you, however that just seems like a query that takes too long to run you should paginate it.

2 Likes

Try passing in inline count parameter to get a total count of your items then use top, skip to loop through the request

 Dictionary<string, string> dic = new Dictionary<string, string>();
dic.add("$top", "100);
dic.add("$inlinecount", "allpages);
EpicorRest.DynamicGet("BaqSvc", "APOTool2", dic);

That returns a new value in your result called odata.count

Which you can then use along with $top and $skip to re-run the query in pieces until you get all your results.

1 Like

I’ll release a new copy of the library with the option to set the timeout. But you should fix the query instead or use paging either way

1 Like

@josecgomez, @Mark_Wonsil, @Jonathan,

Gentlemen, you’re the best! I was able to get the timings fixed on my baq and added the section in the header that points to the proper company. I believe that everything is now working as it should, and it doesn’t time out after 1 minute 40 seconds any more! Thank you all for the assist!! Thumbs up for all, solution to Jose.

3 Likes

Hi Jose,
I have the same problem with timeout, and I use the latest version of API but i not found how set timeout.
please can send me the name of option for timeut settings?

Thanks
Massimo