Hello All,
I’m trying to query a REST API based application from a Web Services - After Operation Rule to get the group memberships of a user from REST API endpoint and update it on the user accounts during aggregation.
The way I’m trying to simplify this is by using the below statements in the rule :
String queryPath = "JSON Query path to get user groups if condition matches";
String RESPONSE = "My JSON response from the target as documented in below section"
for (Map account : processedResponseObject) {
String id = account.getNativeIdentity();
List groups = JsonPath.parse(RESPOSE).read(queryPath, List.class);
account.put(Groups, groups);
}
The above code would store the group membership which matches with the given JSON query path in the “groups” list and will be returned back to response object to be stored under Groups attribute.
However, I’m facing difficulty in constructing the JSON query path for fetching the groups. The way I need the JSON query is :
- From below JSON response, If Resources > members > value == 8122001845556664, then I need its Resources > id as output from the JSON query
{
"totalResults": 2,
"startIndex": 1,
"itemsPerPage": 2,
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:ListResponse"
],
"Resources": [
{
"displayName": "account users",
"members": [
{
"display": "user1, iam",
"value": "8122001845556664",
"$ref": "Users/8122001845556664"
},
{
"display": "user2 iam",
"value": "1410384382558463",
"$ref": "Users/1410384382558463"
}
],
"id": "304938766536524"
},
{
"displayName": "TEST Group",
"members": [
{
"display": "user3, iam",
"value": "7609153611047458",
"$ref": "Users/7609153611047458"
},
{
"display": "user4, iam",
"value": "3303558023366295",
"$ref": "Users/3303558023366295"
}
],
"id": "738595786832639"
}
]
}
Any help with constructing the JSON query to fetch details as mentioned above is really appreciated.
Thanks,
Arshad.