Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

REST; UserImport; Need Information on JSON Response

vivekrajan1
Regular Contributor
Regular Contributor

Hi Team,

I am pasting 2 types of JSON response. I am not sure how to pull record from these response, I require your help provide a sample UserImport JSON for these response.

Type 1: Using UserImport, EIC always want to pull 'results.emails.value' of 'WORK' type and EIC should should ignore HOME or PERSONAL. If 'WORK' type is not available, then EIC should not pass anything. 

"results":
{
"emails": [
{
"value": "stefno.mioli@work.com",
"type": "WORK",
"display": "stefno.mioli@work.com"
},
{
"value": "stefno.mioli@personal.com",
"type": "PERSONAL",
"display": "stefno.mioli@personal.com"
},
{
"value": "stefno.mioli@home.com",
"type": "HOME",
"display": "stefno.mioli@home.com"
}
]
}

Type 2: In this, User will have multiple countries, I should only pull particular country 'name' based on 'Parent_id'. 'Parent_id' is a unique number for each country. 

For ex: For India, Parent_Id is 66e2ec8baafae6cc746a505c

{
"results":
{
"username": "stefno.mioli",
"Country": [
{
"parent_id": "66e2ec8baafae6cc746a505c",
"parent": null,
"name": "India"
},
{
"parent_id": "77e2ec8baafae6cc746a505c",
"parent": null,
"name": "Remote"
},
{
"parent_id": "88e2ec8baafae6cc746a505c",
"parent": null,
"name": "China"
}
]
},
{
"username": "abc.xyz",
"Country": [
{
"parent_id": "66e2ec8baafae6cc746a505c",
"parent": null,
"name": "India"
},
{
"parent_id": "33e2ec8baafae6cc746a505c",
"parent": null,
"name": "France"
},
{
"parent_id": "44e2ec8baafae6cc746a505c",
"parent": null,
"name": "Germany"
}
]
}
}

5 REPLIES 5

rushikeshvartak
All-Star
All-Star
results.emails.value[0]

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

It is not always results.emails.value[0]. because "type": "WORK" path change at times. I need to refer "type" as "Work" always instead of static array value results.emails.value[0]

Example:

"results":
{
"username":"abc",
"emails": [
{
"value": "stefno.mioli@work.com",
"type": "WORK",
"display": "stefno.mioli@work.com"
},
{
"value": "stefno.mioli@personal.com",
"type": "PERSONAL",
"display": "stefno.mioli@personal.com"
}
],
"username":"xyz",
"emails": [
{
"value": "xyz.sample@personal.com",
"type": "PERSONAL",
"display": "xyz.sample@personal.com"
},
{
"value": "xyz.sample@work.com",
"type": "WORK",
"display": "xyz.sample@work.com"
}
}

Use with const def results.emails.find { it.type == "WORK" }?.value


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Hi Rushikesh,

It prints the code as it is(refer the screenshot) if I use #CONST#, I have no idea why it is behaving like this.

vivekrajan1_0-1728646634613.png

UserImportJSON

{
"connection": "acctAuth",
"successResponses":
{
"statusCode": [200,201,202,203,204,205]
},
"url": "https://aabbccdd?URL",
"httpMethod": "GET",
"httpHeaders": {"Authorization": "${access_token}","Accept": "application/json"},
"httpContentType": "application/json",
"userResponsePath": "results",
"colsToPropsMap":
{
"displayname": "xyz.displayname~#~char",
"firstname": "xyz.abc.given_name~#~char",
"lastname": "xyz.abc.family_name~#~char",
"customproperty14":"xyz.id~#~char",
"country":"#CONST#${List responseList = response.results.xyz;for(Map responseMap: responseList){if(responseMap.type.equals('HOME')){return responseMap.xyz}}}~#~char"
},
"pagination": {
"nextUrl": {
"nextUrlPath": "${response?.completeResponseMap?.next_link==null?null:response.completeResponseMap.next_link}"
}
}
}

Share logs


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.