I’m building a flow that needs to fetch another flow’s configuration dynamically. The goal is to get the id of a specific flow by name, then use that id in a subsequent Set Contact Attribute action.
I’m using a action with the GetRESTProxy method. The GET request to /api/v2/flows?name=MyFlow works fine. The response status is 200. The JSON body comes back correctly in the debug log.
Here is the code:
// Get the proxy
proxy = GetRESTProxy()
// Make the call
response = proxy.Get("/api/v2/flows?name=MyFlow")
// Check status
if response.StatusCode == 200 {
// Parse JSON
data = response.Body.ParseJSON()
// Try to get the first entity ID
targetId = data.entities[0].id
// Set attribute
Contact.SetAttribute("targetFlowId", targetId)
}
The issue is data.entities[0].id always returns null.
I checked the raw JSON in the debug output. It looks like this:
{
"entities": [
{
"id": "12345-67890",
"name": "MyFlow",
"version": 1
}
]
}
I’ve tried data.entities.0.id. I’ve tried data.entities["0"].id. I’ve tried looping through data.entities with a FOR EACH block inside the but the syntax for iterating over a JSON array in s is not clear. The documentation just says “parse JSON” but doesn’t show how to drill into arrays.
Is ParseJSON() returning a string that I need to convert again? Or is the array indexing different in the engine?
I also tried using response.Body directly in the IF condition to check for the string “12345-67890”, which works, but that’s not scalable. I need the actual ID value.
What’s the correct syntax to access the first element of a JSON array returned by a REST call in a ?