Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Parse REST API response

GauravJain
Regular Contributor
Regular Contributor

How can we parse such response returned from GET API call. Following is the full response

[
{
"key": "APPLICATION_NAME",
"value": "Gitlab"
},
{
"key": "GROUP_CATEGORY",
"value": "CTB"
},
{
"key": "GROUP_PRIMARY_OWNER",
"value": "Test1"
},
{
"key": "GROUP_SECONDARY_OWNER",
"value": "Test2"
}
]

10 REPLIES 10

adriencosson
Valued Contributor
Valued Contributor

Can you elaborate on the use case to be achieved and what is the data to be pulled from your Get API call response ?

Example : If you want to retrieve the value "Gitlab", you can reach it using the following :

response.call1.message[0].value

 Where "call1" is the name of your Get API call.

Regards,
Adrien COSSON

rushikeshvartak
All-Star
All-Star

which json you want to achieve ?


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Manu269
All-Star
All-Star

Can you please add more insight which operation you are trying to achieve?

Regards
Manish Kumar
If the response answered your query, please Accept As Solution and Kudos
.

GauravJain
Regular Contributor
Regular Contributor

Hi @adriencosson @rushikeshvartak @Manu269 

We are trying to dump Gitlab groups and their custom attributes (part of different REST api) into Saviynt. Following is the entitlementParams configuration. 

"entitlementParams":
{
"connection": "acctAuth",
"processingType": "SequentialAndIterative",
"supportedEntitlementTypes": [
"Group"
],
"entTypes": {
"Group": {
"entTypeOrder": 0,
"call": {
"call1": {
"callOrder": 0,
"stageNumber": 1,
"http": {
"httpHeaders": {
"Authorization": "${access_token}"
},
"url": "https://Valid_Domain/api/v4/groups?per_page=100",
"httpContentType": "application/json",
"httpMethod": "GET"
},
"listField": "",
"keyField": "entitlementID",
"colsToPropsMap": {
"entitlementID": "id~#~char",
"entitlement_value": "name~#~char"
},
"pagination": {
"nextUrl": {
"nextUrlPath": "${headers?.Link?.split(',').size()==4?headers.Link.split(',')[1].replace('<', '').replace('>; rel=\"next\"','').trim():(headers?.Link?.split(',')?.size()==3 && headers?.Link.contains('next')) ?headers.Link.split(',')[0].replace('<', '').replace('>; rel=\"next\"','').trim():null}"
}
},
"makeProcessingStatus": true,
"disableDeletedEntitlements": true
},
"call2": {

"callOrder": 1,
"stageNumber": 2,
"http": {
"httpHeaders": {
"Authorization": "${access_token}"
},
"url": "https://Valid_Domain/api/v4/groups/{hardcoded group id}/members",
"httpContentType": "application/json",
"httpMethod": "GET"
},
"listField": "",
"keyField": "entitlementID",
"colsToPropsMap": {
"customproperty1": "${response.call2.message[0].key}~#~char"
}
}
}
}
}
}

"Call1" pulls all gitlab groups and "Call2" will pull custom attributes of each group. Response format of Call2 is 

[
{
"key": "APPLICATION_NAME",
"value": "Gitlab"
},
{
"key": "GROUP_CATEGORY",
"value": "CTB"
},
{
"key": "GROUP_PRIMARY_OWNER",
"value": "Test1"
},
{
"key": "GROUP_SECONDARY_OWNER",
"value": "Test2"
}
]

first we wanted to see how to retrieve GROUP_PRIMARY_OWNER and GROUP_SECONDARY_OWNER values in customproperty and later populate the same in entitlement owner tab in Saviynt.

"listField": "",
"keyField": "entitlementID",
"colsToPropsMap": {

"entitlementid": "${response.call2.message[0].key}~#~char",

"entitlement_value": "${response.call2.message[0].key}~#~char",
"customproperty1": "${response.call2.message[0].value}~#~char"


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Hi @rushikeshvartak do i need to do this for all custom attributes if above solution works.

"listField": "",
"keyField": "entitlementID",
"colsToPropsMap": {

"entitlementid": "${response.call2.message[0].key}~#~char",

"entitlement_value": "${response.call2.message[0].key}~#~char",
"customproperty1": "${response.call2.message[0].value}~#~char"

"entitlementid": "${response.call2.message[1].key}~#~char",

"entitlement_value": "${response.call2.message[1].key}~#~char",
"customproperty2": "${response.call2.message[1].value}~#~char"

similarly for message[3] and message[4]?

 

Yes


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Thanks @rushikeshvartak for quick revert.

i tried above configuration and my entitlement import job was successful but could not find dumped values inside entitlement_values table, tried with this query 

select * from entitlement_values where entitlementid='APPLICATION_NAME'

if i go to that particular gitlab group (call2 in config) under entitlements then customeproperty1 is blank so not sure where to look for it.

 

"entitlementParams":
{
"connection": "acctAuth",
"processingType": "SequentialAndIterative",
"supportedEntitlementTypes": [
"Group"
],
"entTypes": {
"Group": {
"entTypeOrder": 0,
"call": {
"call1": {
"callOrder": 0,
"stageNumber": 1,
"http": {
"httpHeaders": {
"Authorization": "${access_token}"
},
"url": "https://Valid_Domain/api/v4/groups?per_page=100",
"httpContentType": "application/json",
"httpMethod": "GET"
},
"listField": "",
"keyField": "entitlementID",
"colsToPropsMap": {
"entitlementID": "id~#~char",
"entitlement_value": "name~#~char"
},
"pagination": {
"nextUrl": {
"nextUrlPath": "${headers?.Link?.split(',').size()==4?headers.Link.split(',')[1].replace('<', '').replace('>; rel=\"next\"','').trim():(headers?.Link?.split(',')?.size()==3 && headers?.Link.contains('next')) ?headers.Link.split(',')[0].replace('<', '').replace('>; rel=\"next\"','').trim():null}"
}
},
"makeProcessingStatus": true,
"disableDeletedEntitlements": true
},
"call2": {

"callOrder": 1,
"stageNumber": 2,
"http": {
"httpHeaders": {
"Authorization": "${access_token}"
},
"url": "https://Valid_Domain/api/v4/groups/{hardcoded group id}/members",
"httpContentType": "application/json",
"httpMethod": "GET"
},
"listField": "",
"keyField": "entitlementID",
"colsToPropsMap": {
"entitlementID": "${response.call2.message[0].key}~#~char",
"entitlement_value": "${response.call2.message[0].key}~#~char",
"customproperty1": "${response.call2.message[0].value}~#~char"
}
}
}
}
}
}

Replace supportedEntitlementTypes to entTypes

 

refer samples https://saviynt.freshdesk.com/support/solutions/articles/43000521736-rest-connector-guide%C2%A0#REST...


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Hi @rushikeshvartak tried both replacing and removing "supportedEntitlementTypes" but still not able to find values dumped in entitlement_values table or in customproperty on entitlement UI.