Wednesday, 9 November 2016

Reuse Session during API Calls

Hi All,

If you using Acumatica Web Services you most probably saw the examples where you need to call Login and GetSchema methods before each valuable operation.

This is OK in general, but if you building some complex and high loaded integration as the result you may get something like this:

Not very nice as it creates additional traffic network traffic and unnecessary load to server.

Much better way is to cache Cookies and Schema on the client side and refresh it only if it was not in use for some period of time.

Here I want to share with you an example where I create a new class inherited from Screen and call Login operation automatically before each Submit operation if service was idle for more than 10 minutes.
This static class is more for your idea, i'm pretty sure you may have a better way to do it on the production environment.

Also note that you can encapsulate some additional logic in your class and make your integration code simpler.

Code Snippet:

Have a nice Integration!

No comments: