How to use array element from HTTP response in inline variable inside a loop?

How to use array element from HTTP response in inline variable inside a loop?

I’m building a workflow that loops over devices from Microsoft Intune, searches an external API for each device, then makes a PUT call using a value from the search response. The search response returns an array, and I need to use a field from the first element in the PUT URL.

The problem: I cannot get the originId (an integer) from the search response array into the PUT URL using inline {{ }} variables. I’ve tried every approach I can think of over many hours and none work.


Workflow Structure (simplified)

Get Identity → Get User Devices (Intune) → Loop Over Devices
  └── inside loop:
        Compare Strings (skip specificString)
          → HTTP Request 1 (Search external API)
          → HTTP Request 2 (PUT to external API)

HTTP Request 1 (Search) Response

Returns an array in the body:

{
  "body": [
    {
      "originId": 879845865,
      "name": "DEVICE-NAME"
    }
  ],
  "statusCode": 200
}

HTTP Request 2 (PUT) Needs This URL

https://api.example.com/policies/12345/identities/879845865

The 879845865 must come dynamically from the search response above.


What I’ve Tried

1. Bracket notation in {{ }}

{{ $.hTTPRequest1.body[0].originId }}

Result: Resolves to empty string. API returns "identityId must be a number".


2. Dot notation in {{ }}

{{ $.hTTPRequest1.body.0.originId }}

Result: Same — resolves to empty string.


3. Define Variable operator to extract the value

Configured Define Variable with:

  • variableA.$ = $.hTTPRequest1.body[0].originId
  • No transforms

The .$ extraction works perfectly. Execution history shows:

"defineVariable": {
  "deviceOriginId": 879845865
}

But using it in the PUT URL:

{{ $.defineVariable.deviceOriginId }}

Result: Still resolves to empty string.


4. Define Variable + .JSON() function

{{ $.defineVariable.deviceOriginId.JSON() }}

Result: Same empty string result.


5. Define Variable + Substring transform (force string conversion)

Added a Substring transform (start: 0, length: 20) to the Define Variable to coerce the integer to a string.

Result: IndexOutOfBoundsErr: length: 0 — the Substring transform cannot operate on the integer value.


6. Define Variable + Concatenate transform (build full URL)

Set Variable A to the static URL prefix and tried to Concatenate the dynamic originId.

Result: Concatenate’s Variable B only accepts static values, not dynamic .$ references. Using .$ in the Advanced editor returns "error parsing input".


7. Nested loop over search results

Attempted to add a sp:loop:iterator inside the existing loop to iterate over $.hTTPRequest1.body, which would make $.loop.loopInput.originId available without array indexing.

Result: SailPoint does not support nested loops.


What I’ve Confirmed

  • The .$ suffix correctly resolves $.hTTPRequest1.body[0].originId to 879845865 (visible in execution history under the Define Variable output)
  • All working {{ }} expressions in my workflow reference string values from action-type steps:
    • {{ $.getIdentity.attributes.email }} — works
    • {{ $.loop.loopInput.deviceName }} — works
  • The {{ }} interpolation appears unable to reference Define Variable (Mutation-type) step outputs
  • Both sp:http steps use version 3 with built-in OAuth

My Questions

  1. Is there a supported way to access an array element inside {{ }} inline variables?
  2. Can {{ }} reference Define Variable (Mutation-type) step outputs? If so, what is the correct syntax?
  3. Is there another approach entirely for getting a value from an HTTP response array into a subsequent HTTP request URL?

Using ISC (SaaS), workflow builder. Any help is greatly appreciated! I’ve been stuck on this one issue and the rest of the workflow runs end-to-end perfectly.

Generally, you have three options:

  1. Handle your ‘workflow’ programatically externally (e.g. PowerShell SDK, Python SDK…etc).
  2. Shift the workflow out to another more capable / centralised / enterprise-grade workflow engine (n8n or whatever else you have), instead of handling complex workflow in a ‘relatively’ limited and niche workflow engine of ISC.
  3. If you must handle it within the tenant of ISC, potentially this to handle value extraction: How to date transform in a workflow - #6 by David_Norris

With recent progress in vibe coding, one may say that the technical hurdle for options 1 and 2 are now lower than before. ISC workflow has its own set of limitations (e.g. nondeterministic out-of-order loop iteration, loop iteration limit unless you do recursive workflow…etc.)

From your explanation, the JSONPath extraction is working, but the inline interpolation in the HTTP URL field is not. The execution history shows $.hTTPRequest1.body[0].originId is being resolved correctly in the Define Variable step, so the problem is not the array lookup itself.

Based on your example, I would treat this as a workflow engine limitation in URL interpolation, especially since:

  • direct array access in {{ }} resolves empty,
  • the value is visible in Define Variable,
  • and {{ $.defineVariable.deviceOriginId }} still resolves empty in the next HTTP step.

My recommendation would be:

  1. Keep the extraction in a Define Variable step:

deviceOriginId.$ = $.hTTPRequest1.body[0].originId

  1. Add a guard before the PUT call to make sure body[0] actually exists for that iteration.
  2. If the URL field still will not accept the resolved value, assume this is not a syntax issue but a product limitation in that field/runtime path. At that point, the practical options are:
  • move the dynamic API chaining outside ISC,
  • or redesign the call so the dynamic value is passed somewhere other than the URL path if the target API supports it.