Click HERE to see how Saviynt Intelligence is transforming the industry. |
10/09/2024 03:24 AM
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"
}
]
}
}
10/09/2024 11:24 AM
10/09/2024 01:04 PM
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"
}
}
10/09/2024 01:47 PM
Use with const def results.emails.find { it.type == "WORK" }?.value
10/11/2024 04:42 AM
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.
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}"
}
}
}
10/11/2024 08:29 AM
Share logs