Multiple API Requests in For Each Loop

Multiple API Requests in For Each Loop


As usual, I'm probably in the wrong forum. Here's what I'm trying to do:

I have 2,000+ records that I am passing from my OutSystems application to an external application via API. I've managed to make individual POSTs via the API, but I don't know how to loop through all 2,000 records to "push" all values through the API.

Any thoughts?

Hi Aaron,

I'm not sure why you think this is the wrong forum? Anyway, are you familiar with the ForEach statement? Looping through a List of Records and doing something with those records is so very basic to OutSystems programming, you can hardly have missed it?


Thanks for the vote of "confidence". I'm both new to development and newer to OutSystems. I'm famiiliar with a For Each loop, just not how to change what I'm passing to a REST API in a For Each loop.

As I stated in my example, I'm trying to "copy" 2,000 records from OutSystems to an external database. I don't know how to do that.

I don't know the specifics of your OS app, the external app, or the API... but I'd try very hard not to loop through 2000 records to send them.  Was your intention to make 2,000 API calls?  If so, can you see how that's probably not the best process?

Can your external app not "get" the data from the same place your OS app gets it?  Probably not, since that's why you've posted... but I still have to ask.

Could you update a remote database where your external app could then get at that data?

Big records?  Could you build blocks of records to send?  E.g. 200 records at a time?

I'd be content to send all 2,000 at a time. They're really small records (2 columns of data each). If there's a way to send all 2,000 at once, I'm all ears.

This is just theory, but I'd think about looping through the 2000 records building JSON, and then sending that string through.  I don't know what your API can handle... or what your external app is expecting.

I actually started looking at serializing JSON. My API should be able to handle it, I think. I'll tinker. Thank you for your suggestions.

I'm quite interested in how it comes along.  I'm still finding my way around OutSystems.

If you are talking to a REST API, and that REST API supports a list of records, you can just just pass the List, no need to explicitly serialize anything. There's plenty of online documentation about REST APIs, I'd suggest you take a look there.

 So you want to pass 2000 records at once, and each record is only 2 columns, if its just a couple of strings then I think the size of what you are trying to pass is not a problem ( payload is not high), so then, you can simply the list of records as an input to the API.

Look at this:

Also, if at any time you think its too much data ( the 2000 records) and then the call is too slow, then you can batch it, by simply using the for each properties ( startIndex and maximum iterations), this should give you enough handling for you to pass to the rest api, lets say, 200 records at a time. Of course this problem can have tons of solutions and it depends on your API, you app you DB... So, better descriptions give you better answers ;) , hope it helps!


it's more of the external DB issue than actual outsystems.

heck, if it's a simple external DB, you might opt to go for the integration-studio variant.