Skip to main content

Iteration Map Example

Conditional SWITCH Example

Iterate over an array of strings.

Then, upcase each letter using string/upcase action

Example Configuration

Learn how to use

Supporting Concepts

Basic concepts needed for the use case
APIAn API in API AutoFlow is simply an OpenAPI model
ServerA server accepts and handles the request and response.
SimulationData simulation is a mock data simulated for the purpose of visualizing the data in every step of the workflow.
  • Simulated data is NOT the real data but a sample data you create.
  • To use real data, use the Transaction feature to capture the data you send from Postman or CURL.
ScopeA scope is a namespace for variables.
Data TypesData types describe the different types or kinds of data that you are gonna store and work with.
Use case specific concepts
Iterate over array of data mapping result to each array position.
Returns a string where converts all characters in the given string to uppercase.


The HTTP request body has an array with 2 values:

Original array

[ "foo1", "foo2" ]

The goal of the operation is to iterate over the array and create a new array:

New array (after iteration)

[ "FOO1", "FOO2" ]



1: Create an API endpoint

Required Concepts

Learn how to create an API.

Create an API

From the left navigation, go to the API section and create a new API.

Create API
  • ID: sample-iteration
Create an API Path
Create API Path
  • Path: /map
  • Method: POST

2. Create a Server Operation

Required Concepts

Learn how to create a Server.

Create a Server

From the left navigation, go to the Server section and create a new Server.

Create Server
  • Server ID: sample-iteration
  • Port Number: 1112 Feel free to select your own port number
  • Linked API: sample-iteration (select the API you created above)
Create a Server Operation
Create Server Operation
  • Press the "Add API Operation"
  • Select the API endpoint created above

3 : Create Data Simulation using Real Data

Required Concepts

Learn how to create a Simulation.

We will use the "real data" to create the test simulation.

1. Send a HTTP request from Postman or cURL
Send Postman Request

API Autoflow Postman Collections

curl --location 'localhost:1112/map' \
--header 'Content-Type: application/json' \
--data '[
2. Check the data is received by the server endpoint

API Autoflow captures the data received and it can be used to create data simulation.



Required Concepts

Learn how to create a Actions.

Add actions to transform the data.

1. Iterate over the input array.

Required Concepts

Learn how to create a Iteration/map.

Iteration Map
Iteration Map

Iteration: data

[request: body]

Scope: string

Iteration Scope

Scope loop-var stores each value from the array.

  • Makes the value available inside the iteration one-by-one. The 1st value is available to be used for configuration.
Upcase the Value
String Upcase
String Upcase

string: data

[request: body > value]


variables: output


variables: output


1. Create a NEW object and map the IP and Subnet

Both the action's output and HTTP response body are set to variables: output. There's no change that needs to be made.

HTTP Response
Server Workflow Default Output

body: data

[variables: output]

Mapping the action output to the HTTP response output
  • Data referenced in HTTP response is what gets sent back to the client.
  • Map the output from the actions to be sent back.

NOTE: By default, the action output is set to variable output. If you intend to keep each action's output without it being overwritten by the next action, simply rename the output location in the action's output.

2. Test the API with Postman or CURL

curl --location 'localhost:1112/map' \
--header 'Content-Type: application/json' \
--data '[