Sample scenario

This example shows how you can create an input array using JQTransform and Do-while steps.
  1. Define the API Flow Properties on the API Flow Properties page.
    • This table shows the information that you must specify on the Request tab:
      Field name Value
      Endpoint Name do-while_demo
      Endpoint Path do-while_demo
      Method POST
      Resource Name do-while_demo
      Resource Path do-while_demo
    • This table shows the information that you must specify on the Request Body tab:
      Field name Value
      Presence Required
      Content Type application/json
      Name body
      Schema
      {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "type": "object",
        "properties": {
          "array": {
            "type": "array",
            "items": [
              {
                "type": "string"
              },
              {
                "type": "string"
              }
            ]
          }
        },
        "required": [
          "array"
        ]
      }
      
      Example
      {
                      "array": ["first", "second"]
      }
      
    • This table shows the information that you must specify on the Response Body tab:
      Field name Value
      Content Type application/json
      ApiFlow Response Status Code 200
      Body
      "${DoWhile1.output}"
  2. Drag a Do-While task into the API Flow and specify the required information on the Do While Properties page.
    • This table shows the information that you must specify on the Properties tab:
      Field name Value
      Name DoWhile1
    • This table shows the information that you must specify on the Do While Parameters tab:
      Field name Value
      Name array
      Value
      ${input.body}.array
    • This table shows the information that you must specify on the Conditions tab:
      Field name Value
      Expression
      if ($.DoWhile1['iteration'] < $.array.length) true; else false

    The expression continues the loop if the iteration is less than the array value, otherwise it exits the loop.

  3. Drag a JQ Transform task into the API Flow and specify the required information on theJQTransform Properties page.
    • This table shows the information that you must specify on the Properties tab:
      Field name Value
      Name JQTransform1
    • This table shows the information that you must specify on the JQTransform Parameter tab:
      Field name Value
      Name JSONJQINPUT
      Value
      {
      "input": "${input.body}.array",
      "iterator": "${DoWhile1.output}.iteration"
      }
      

      This sets the body as having input and iterator to have the values for array and iteration value for the do-while.

    • This table shows the information that you must specify on the JQ Filter tab:
      Field name Value
      Expression
      .input[.iterator - 1]

      This sets the value JQTransform1.output to the value of the array to that iteration position.

  4. Add the ION API task and specify the required information on the ION API Properties page.
    • This table shows the information that you must specify on the ION API tab:
      Field name Value
      Name proxy
      Product EAM_SOAP_webservice
      Operation Post

      CustomerApi/httpbin/proxy/anything

      Optional No

      In this case an Httpbin is used to post a body.

    • This table shows the information that you must specify on the Request Body tab:
      Field name Value
      Content Type application/json
      Name Body
      Body
      {"org":"${JQTransform1.output}"}
    • This table shows the information that you must specify on the Output Parameters tab:
      Field name Value
      Response Content Type application/json
      Name response2
      Response Type BODY

This screenshot shows how the full API flow should be:

Sample API flow with a do-while step

To test this, send an array. For example:

{
	"array": ["first", "second", "Third", "Fourth"]
}

In the result there should be four iterations with JQTransform Output and ION API Response2 output.