JSON Array Handling
Connectors may return their payload as an array of items. In the example below, we showcase configuring the connector action and utilizing the returned array data to update a user's properties, such as their phone number.
This flow takes the user's email and then queries an API to verify if the email exists as a user in a 3rd party system through the HTTP Connector, and if so, update their user information to include their phone number.
Configure Connector Action
The first step is to configure your connector action. You will later need to use the Context Key
of
the connector's data; in this example, the data is stored under connectors.httpResult
.
Get Data from Array
Next, we can access the data from the returned array from other Descope actions or conditionals, before we try to access it though, here is an example of it's contents.
Now we will access the array; in this example, we will use the Update User/ Properties
action to get data
from the array and update the user's phone number and verification status.
Based on the above returned data under the connectors.httpResult
context key, we will need to parse out the
phone details per the below paths using jquery.
jq:.connectors.httpResult.body.data[0][].phone.verified
jq:.connectors.httpResult.body.data[0][].phone.number
Connecting the Flow
Once you have configured the connector action and the condition or other action to parse the data via jquery, you can now connect the flow. Here is the flow in this example once completed.
Post Flow Execution
Below you can see the user's details are updated after the flow execution.