Long running Scripted REST API

Miles Clark
Tera Contributor

I'm building a Scripted REST API that takes in an array of JSON objects.  Each object in the array needs to be processed, and in some cases the processing takes long enough so that the entire request times out.

 

Any suggestions on the best way to handle this?  I'm attempting to use GlideImportSetTable, GlideImportSetTransformer, etc. to insert the data into an import set and apply a transform map to it.  I'm struggling with loading the data from the REST call into the import set tables, and generally how to connect the dots.

 

The other approach I'm considering is to load the data into a custom table and use Business Rules to process it.

 

Any advice would be appreciated - thanks!

 

1 ACCEPTED SOLUTION

James Chun
Kilo Patron

Hey @Miles Clark,

 

If your JSON object is not too 'big', another option is to trigger Events and process them via Script Action.

I guess it comes down to what you are doing with that JSON object.

 

Thanks

View solution in original post

4 REPLIES 4

pablo_itguy_pl
Mega Guru

Hi,

 

Couple ideas here:

1. Quick and dirty - import set table + transform map -> take the request body, parse it into array of objects, iterate through it and push each object as separate record to import set table.

2. If you have IntegrationHub Ent subscription - there is a REST API trigger - so pushing the data to custom endpoint will trigger flow that can do data processing.

3. Use the idea of REST API trigger - in scripted REST API use ScriptableFlowRunner API to run custom subflow that will take request body as input and will process the data. I think I would go with this one as once you trigger flow/subflow you have the access to contextId of the execution - push this as response and have additional scripted API created to check the status of data processing flow execution.

Great ideas - thanks!

James Chun
Kilo Patron

Hey @Miles Clark,

 

If your JSON object is not too 'big', another option is to trigger Events and process them via Script Action.

I guess it comes down to what you are doing with that JSON object.

 

Thanks

Hi @James Chun 

 

That's exactly what I ended up doing - thanks!

 

Miles