Integration with Split
Description
Below is the description of the executed steps:
-
The flow begins with a
GET
request to the/startflow
endpoint.
- from:
Description: REST endpoint that triggers the flow
uri: rest:get:/startflow
-
Then, the flow makes another
GET
request to an endpoint that returns a list of items.
steps:
- toD:
uri: https://example.com/api/list
parameters:
bridgeEndpoint: true
httpMethod: GET
-
The response from the
GET
request is treated as JSON and is deserialized using the Jackson library. This allows the flow to handle the data as objects rather than just plain text.
- unmarshal:
json:
library: Jackson
-
The next step splits the JSON response (presumably a list) so that each item can be processed individually. The expression
${body}
refers to the content of the response that was deserialized in the previous step.
- split:
expression:
simple:
expression: ${body}
-
The Choice defines that for each item in the list:
-
If the
value
is greater than10
, aPOST
is sent tohttps://example.com/api/true-endpoint
.
-
steps:
- choice:
when:
- expression:
simple: "${body[value] > 10}"
steps:
- toD:
uri: https://example.com/api/true-endpoint
parameters:
bridgeEndpoint: true
httpMethod: POST
-
Otherwise, a
POST
is sent tohttps://example.com/api/false-endpoint
.
otherwise:
steps:
- toD:
uri: https://example.com/api/false-endpoint
parameters:
bridgeEndpoint: true
httpMethod: POST
Flow Script
Below is the full script of the described integration flow:
- from:
Description: REST endpoint that starts the flow
uri: rest:get:/startflow # Endpoint that starts the flow
steps:
- toD:
uri: https://example.com/api/list # GET request to retrieve the list of items
parameters:
bridgeEndpoint: true
httpMethod: GET # Defining the HTTP method as GET
- unmarshal:
json:
library: Jackson # Using the Jackson library to deserialize the JSON response
- split:
expression:
simple:
expression: ${body} # Splitting the response (assuming it's a list) to iterate over the items
steps:
- choice:
when:
- expression:
simple: "${body[value] > 10}" # Condition to check if the 'value' field is greater than 10
steps:
- toD:
uri: https://example.com/api/true-endpoint # Endpoint to be called if the condition is true
parameters:
bridgeEndpoint: true
httpMethod: POST # HTTP POST method
otherwise:
steps:
- toD:
uri: https://example.com/api/false-endpoint # Endpoint to be called if the condition is false
parameters:
bridgeEndpoint: true
httpMethod: POST # HTTP POST method
Share your suggestions with us!
Click here and then [+ Submit idea]