ISC Workflow - Convert String into JSON

Hi,

I am writing a workflow which fetches the events and uses that data for further processing. The data I am interested in looks like this:

“IdnAccessRequestAttributes”: “{"deniedCommentsRequired":false,"requestedObjectId":"785d141225f34ad7b330a5e188b70567","accessRequestType":"REVOKE_ACCESS","requestedObjectDescription":"Okta role","requestedObjectName":"Bobby - Test Okta","requestedObjectType":"ROLE"}”

I am able to access IdnAccessRequestAttributes using JSON Path but it returns the data as string. I would like to convert this String into JSON or Map using Java APIs as I need to extract data from within this string e.g. I want to extract the value of requestedObjectId. Is there any way to do this in Workflow?

Thanks,
Gaurav

ISC workflow does not have capability to do these operations, but you should be able to get ‘requestedObjectId’ using jsonpath like

$.requestedObjectId

Unfortunately, that does not work.

$.attributes.IdnAccessRequestAttributes gives the following:

[
  "{\"deniedCommentsRequired\":false,\"requestedObjectId\":\"785d141225f34ad7b330a5e188b70567\",\"accessRequestType\":\"REVOKE_ACCESS\",\"requestedObjectDescription\":\"Okta role\",\"requestedObjectName\":\"Bobby - Test Okta\",\"requestedObjectType\":\"ROLE\"}"
]

But $.attributes.IdnAccessRequestAttributes.requestedObjectId does not match anything.

Can you try this and if possible share your JSON?

$.attributes.IdnAccessRequestAttributes[?(@.accessRequestType==‘REVOKE_ACCESS’)].requestedObjectId

With this type of format:

[
“{"deniedCommentsRequired":false,"requestedObjectId":"785d141225f34ad7b330a5e188b70567","accessRequestType":"REVOKE_ACCESS","requestedObjectDescription":"Okta role","requestedObjectName":"Bobby - Test Okta","requestedObjectType":"ROLE"}”
]

You can try also : $.attributes.IdnAccessRequestAttributes[0].requestedObjectId

If your $.attributes.IdnAccessRequestAttributes is an array you itterate on it by using workflows.

Sorry, it did not work.

It did not work, sorry!!

@gaurav_jain can you please confirm your input data ?

"attributes": {
            "accountName": "Test User",
            "attributeName": "assignedRoles",
            "attributeValue": "Bobby - Test Okta [cloudRole-1694622119513]",
            "flow": "appRequest",
            "IdnAccessRequestAttributes": "{\"deniedCommentsRequired\":false,\"requestedObjectId\":\"785d141225f34ad7b330a5e188b70567\",\"accessRequestType\":\"REVOKE_ACCESS\",\"requestedObjectDescription\":\"Okta role\",\"requestedObjectName\":\"Bobby - Test Okta\",\"requestedObjectType\":\"ROLE\"}",
            "info": "Bobby - Test Okta",
            "interface": "LCM",
            "operation": "RoleRemove",
            "sourceName": "IIQ"
        }

Hi @gaurav_jain,

Can you share the full JSON ?

Thanks,
Shailee

[
	{
		"_type": "event",
		"_version": "v2",
		"action": "RoleRemove",
		"actor": {
			"name": "test.user1"
		},
		"attributes": {
			"accountName": "Test User",
			"attributeName": "assignedRoles",
			"attributeValue": "Test Okta [cloudRole-1694622119513]",
			"flow": "appRequest",
			"IdnAccessRequestAttributes": "{\"deniedCommentsRequired\":false,\"requestedObjectId\":\"785d141225f34ad7b330a5e188b70567\",\"accessRequestType\":\"REVOKE_ACCESS\",\"requestedObjectDescription\":\"Okta role\",\"requestedObjectName\":\"Test Okta\",\"requestedObjectType\":\"ROLE\"}",
			"info": "Test Okta",
			"interface": "LCM",
			"operation": "RoleRemove",
			"sourceName": "IIQ"
		},
		"created": "2023-09-13T17:14:50.102Z",
		"id": "3e95ad4b24ab1283e32290bec6d124db0fc6f82460c7ec60331f589386c0aad0",
		"name": "Remove Role Passed",
		"objects": [
			"ROLE"
		],
		"operation": "REMOVE",
		"org": "testorg",
		"pod": "testpod",
		"stack": "wps",
		"status": "PASSED",
		"synced": "2023-09-13T17:14:50.432Z",
		"target": {
			"name": "Test User"
		},
		"technicalName": "ROLE_REMOVE_PASSED",
		"trackingNumber": "0f97adc460334f34aa7ebe25c2467812",
		"type": "ACCESS_ITEM"
	}
]

Hi @gaurav_jain ,

The JSON string contains IdnAccessRequestAttributes in a string format and Workflows currently cannot convert String to JSON. Hence there are multiple combinations of steps required in the workflow to fetch the requestedObjectId

Below would be not one of the most elegant way to extract the requestedObjectId value but you can give it a try:

Assuming that your input is as above shared (copied in formatted string as below):

[
    {
        "_type": "event",
        "_version": "v2",
        "action": "RoleRemove",
        "actor": {
            "name": "test.user1"
        },
        "attributes": {
            "accountName": "Test User",
            "attributeName": "assignedRoles",
            "attributeValue": "Test Okta [cloudRole-1694622119513]",
            "flow": "appRequest",
            "IdnAccessRequestAttributes": "{\"deniedCommentsRequired\":false,\"requestedObjectId\":\"785d141225f34ad7b330a5e188b70567\",\"accessRequestType\":\"REVOKE_ACCESS\",\"requestedObjectDescription\":\"Okta role\",\"requestedObjectName\":\"Test Okta\",\"requestedObjectType\":\"ROLE\"}",
            "info": "Test Okta",
            "interface": "LCM",
            "operation": "RoleRemove",
            "sourceName": "IIQ"
        },
        "created": "2023-09-13T17:14:50.102Z",
        "id": "3e95ad4b24ab1283e32290bec6d124db0fc6f82460c7ec60331f589386c0aad0",
        "name": "Remove Role Passed",
        "objects": [
            "ROLE"
        ],
        "operation": "REMOVE",
        "org": "testorg",
        "pod": "testpod",
        "stack": "wps",
        "status": "PASSED",
        "synced": "2023-09-13T17:14:50.432Z",
        "target": {
            "name": "Test User"
        },
        "technicalName": "ROLE_REMOVE_PASSED",
        "trackingNumber": "0f97adc460334f34aa7ebe25c2467812",
        "type": "ACCESS_ITEM"
    }
]
  1. You can first define a variable in the workflow to get the index of requestedObjectId in the value fetched for$.attributes.IdnAccessRequestAttributes :

  1. As the next step, you can define another variable and use this index from the preceding Define Variable to get the requestId value like below:

Your workflow would have these two steps added where the second Define Variable : requestId has the value 785d141225f34ad7b330a5e188b70567. You can use it as $.defineVariable.requestId in the subsequent steps

I hope this helps your case.

Thanks,
Shailee

2 Likes

Thanks Shailee!! I appreciate the effort you have put in to respond to my rquestion. It works for requestedObjectId but will not work for others as it has hardcoded index and length values. I am afraid that the code will break if for whatever reason index and length changes. Can you think of any other better way to achieve that?

Hi @gaurav_jain ,

Just a thought on your use case, if it suits here - If your use case is to capture the requestObjectId or IdnAccessRequestAttributes.attributes after the request of an access, you can use PowerShell script instead of Workflows. An “After Modify Rule” can be used to trigger the PowerShell script and within the PowerShell script you will be able to parse the required response objects more neatly.

I hope this suggestion helps.

Thanks,
Shailee

Thanks for the suggestions Shailee!! But with the help of @IAMpdu, I was able to convert that string into JSON. Basically, we passed the String to a fake URL and got the output in JSON.

“HTTP Request 1”: {
“actionId”: “sp:http”,
“attributes”: {
“authenticationType”: “basic”,
“basicAuthPassword”: “$.secrets.e60445de-6cd0-4988-8ea4-209b6b86d877”,
“basicAuthUserName”: “test”,
“jsonRequestBody.$”: “$.hTTPRequest.body[0].attributes.IdnAccessRequestAttributes”,
“method”: “post”,
“requestContentType”: “json”,
“url”: “https://jsonplaceholder.typicode.com/posts
},
“displayName”: “Parse String into JSON”,
“nextStep”: “Manage Access”,
“type”: “action”,
“versionNumber”: 2
}

1 Like

Be careful when using third party websites to do this. You don’t know who operates those sites and the data you send to them may be captured. Whatever data you send should not contain PII or other sensitive information.

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.