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

REST Connector: Sample Add Access & Remove Access Json With Full Entitlement List Needed

Sivagami
Valued Contributor
Valued Contributor

We have a REST Application that doesn't have calls for adding/removing a single entitlement. I always have to update the account with the complete list of needed entitlements.

Example 1:

User has entitlements A and B. Additionally he should receive C. I have to send user update call with:

 

{
  "id": "userid",
  "groups": [
    {
      "value": "A"
    },
    {
      "value": "B"
    },
    {
      "value": "C"
    }
  ]
}

 

Example 2:

User has entitlements A, B and C. B should be removed. I have to send user update call with:

 

{
  "id": "userid",
  "groups": [
    {
      "value": "A"
    },
    {
      "value": "C"
    }
  ]
}

If anyone has already done this, could you share the Add Access & Remove Access json sample?

Appreciate the support.

-Siva

 

3 REPLIES 3

rushikeshvartak
All-Star
All-Star

You can use 2 calls in this case first retrieve current groups assigned to user & then in second api call i.e. add/ remove use previous response & add/remove new group in array


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

Thanks Rushikesh for the response. I tried it already, but kept receiving json parse error for call 2. Hence, looking for a sample with json content type. I see sample in coupa connector documentation but that's XML content type.

https://saviynt.freshdesk.com/support/solutions/articles/43000563343-coupa-connector-guide#CoupaConn... 

Here is the sample json I'm using, Call 1 is executing successfully but call 2 is throwing json parse error. 

 

{
  "call": [
    {
      "name": "Groups",
      "connection": "acctAuth",
      "url": "https://myapp.mydomain.com/rest/Users/${account.accountID}",
      "httpMethod": "GET",
      "httpHeaders": {
        "Accept": "application/scim+json",
        "Authorization": "${access_token}"
      },
      "httpContentType": "application/scim+json",
      "successResponses": {
        "statusCode": [
          200
        ]
      }
    },
    {
      "name": "Groups",
      "connection": "acctAuth",
      "url": "https://myapp.mydomain.com/rest/Users/${account.accountID}",
      "httpMethod": "PUT",
      "httpParams": "{\"id\": \"${account.accountID}\",\"groups\":  ${String groupsStr = '';int size = response.Groups1.message.groups?.size(); if(size == 0) {'[{}]'} else { response.Groups1.message.groups.replace(']','').concat(',{\"value\":\"${entitlementValue.entitlement_value}\"}]')}}}",
      "httpHeaders": {
        "Accept": "application/scim+json",
        "Authorization": "${access_token}"
      },
      "httpContentType": "application/scim+json",
      "successResponses": {
        "statusCode": [
          200
        ]
      }
    }
  ]
}

 

Parse Error received in logs

 

2022-09-14 16:12:40,374 [quartzScheduler_Worker-25] ERROR rest.RestProvisioningService  - Exception in creating original http params:com.fasterxml.jackson.core.JsonParseException: Unrecognized token '$': was expecting ('true', 'false' or 'null')
 at [Source: {"id": "${account.accountID}","groups":  ${String groupsStr = '';int size = response.Groups1.message.groups?.size(); if(size == 0) {'[{}]'} else { response.Groups1.message.groups.replace(']','').concat(',{"value":"${entitlementValue.entitlement_value}"}]')}} }; line: 1, column: 43]
2022-09-14 16:12:40,412 [quartzScheduler_Worker-25] DEBUG rest.RestProvisioningService  - connection: acctAuth
2022-09-14 16:12:40,505 [quartzScheduler_Worker-25] ERROR rest.RestProvisioningService  - Error in processWebservicecom.fasterxml.jackson.core.JsonParseException: Unrecognized token '$': was expecting ('true', 'false' or 'null')
 at [Source: {"id": "${account.accountID}","groups":  ${String groupsStr = '';int size = response.Groups1.message.groups?.size(); if(size == 0) {'[{}]'} else { response.Groups1.message.groups.replace(']','').concat(',{"value":"${entitlementValue.entitlement_value}"}]')}} }; line: 1, column: 43]
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error com.fasterxml.jackson.core.JsonParseException: Unrecognized token '$': was expecting ('true', 'false' or 'null')
 at [Source: {"id": "${account.accountID}","groups":  ${String groupsStr = '';int size = response.Groups1.message.groups?.size(); if(size == 0) {'[{}]'} else { response.Groups1.message.groups.replace(']','').concat(',{"value":"${entitlementValue.entitlement_value}"}]')}} }; line: 1, column: 43]
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558)
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._reportInvalidToken(ReaderBasedJsonParser.java:2839)
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1903)
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextFieldName(ReaderBasedJsonParser.java:972)
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:505)
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:362)
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:27)
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3814)
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2877)
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.fasterxml.jackson.databind.ObjectMapper$readValue.call(Unknown Source)
2022-09-14 16:12:40,506 [quartzScheduler_Worker-25] DEBUG println.PrintlnToLogger  - Println :: | Error 	at com.saviynt.provisoning.rest.RestProvisioningService.processWebservice(RestProvisioningService.groovy:8054)

 

 

 

How to avoid this parse error?

 

Sivagami
Valued Contributor
Valued Contributor

Any updates here?