Workflow HTTP request body parsing error

Hello all,

I am trying to use a workflow where :

  • I call the ICS’ API to get all Access review items of a campaign certification
  • Call another workflow through API with as input the response from the request above

This does work when I use the “Choose Variable” setting to select the $.hTTPRequest.body but it doesn’t when I use the “Enter Value” setting with the double brackets : {{$.hTTPRequest.body}}.

I have the following error : “Unable to parse input as JSON, please ensure it is syntactically correct. (type: Error Parsing Input, retryable: false): invalid character ‘m’ looking for beginning of value”

This works ok :

This doesnt :

I need to use the value option because I want to add additional information on the body such as :

{
"additionalData":"thisdata",
"body":" {{$.hTTPRequest.body}}"
}

Is there a particular way to proceed with this ?

Thanks all

Hi David,
You can reference multiple values and add several items to your request body from different steps, or static values. See the below as an example…

{
       "attributes": {
           "id": "{{$.getIdentity.attributes.identificationNumber}}",
           "name": "{{$.getIdentity.attributes.identificationNumber}}",
           "process": "Leaver",
           "sourceId": "sourceID",
           "ticketNumber": "{{$.trigger.requestNumber}}"
       }
}

If you didn’t want to follow the above approach, try using a define variable step (Operators - SailPoint Identity Services ) and concatenating the two values together. From there, you can use the Define Variable step output in your json body.
Thanks,
Margo

1 Like

Hi David,

Could you send an example of what the body of the API call is? Or what ISC API you are calling to get this data?

When the ‘{{$.hTTPRequest.body}}’ variable evaluates it could be creating an invalid JSON format within the body attribute.

Thanks,

Liam

Hi David,

Try to pass like below hope it would help

"body":"{{$.hTTPRequest.body}}"

Hi Liam,

Indeed I do believe that the API response is somehow being parsed incorrectly thus the error that arise.

The API is list-identity-access-review-items | SailPoint Developer Community

And the response that I am trying to use is an array of access items like this :

[
    {
        "id": "2ddf2e54a70b407b8578263a1bd63e35",
        "completed": false,
        "newAccess": true,
        "decision": null,
        "comments": null,
        "accessSummary": {
            "access": {
                "type": "ACCESS_PROFILE",
                "id": "9af81c3f51b3401b84b7651aede84835",
                "name": "DTR - AP 2"
            },
            "entitlement": null,
            "accessProfile": {
                "id": "9af81c3f51b3401b84b7651aede84835",
                "name": "DTR - AP 2",
                "description": null,
                "privileged": false,
                "cloudGoverned": false,
                "endDate": null,
                "owner": {
                    "email": "[email protected]",
                    "type": "IDENTITY",
                    "id": "xxxxxx",
                    "name": "toto toto (toto)"
                },
                "entitlements": [
                    {
                        "id": "fe0b90aae88f46459f6e29db6d469eea",
                        "name": "dtr-test-group-2",
                        "description": null,
                        "privileged": false,
                        "owner": null,
                        "attributeName": "groups",
                        "attributeValue": "85644d27-3b37-45a9-b58b-41a2ae78e4c7",
                        "sourceSchemaObjectType": "group",
                        "sourceId": "966376b439494b2f87554e28e414f565",
                        "sourceName": "Azure AD",
                        "sourceType": "Azure Active Directory",
                        "hasPermissions": false,
                        "isPermission": false,
                        "revocable": false,
                        "cloudGoverned": false,
                        "account": {
                            "nativeIdentity": "7d6d8b06-5c9d-4074-b73a-2d1512bf3167",
                            "disabled": false,
                            "locked": false,
                            "type": "ACCOUNT",
                            "activityInsights": null,
                            "description": null,
                            "owner": null,
                            "governanceGroupId": null,
                            "id": "5edcc0f2babd42c59ecf0057d78f1cd3",
                            "name": "[email protected]",
                            "created": "2023-03-16T13:35:18.468Z",
                            "modified": "2024-11-13T17:06:32.972Z"
                        },
                        "dataAccess": null,
                        "containsDataAccess": false
                    }
                ],
                "created": "2024-11-13T10:40:19.843Z",
                "modified": "2024-11-13T10:40:31.865Z"
            },
            "role": null
        },
        "identitySummary": {
            "id": "c5776b918da74401b7aaaa94bf4fe30a",
            "name": "Bakys Syfufi",
            "identityId": "8d59ef025a90470e99dd4de8dcf7a1e3",
            "completed": false
        }
    },
    {
        "id": "8d2e0edb29e24ac1a7b8419072b7f304",
        "completed": false,
        "newAccess": true,
        "decision": null,
        "comments": null,
        "accessSummary": {
            "access": {
                "type": "ROLE",
                "id": "a33824613af341f5a0935c611e256950",
                "name": "DTR - Role 1"
            },
            "entitlement": null,
            "accessProfile": null,
            "role": {
                "id": "a33824613af341f5a0935c611e256950",
                "name": "DTR - Role 1",
                "description": "Role containing access profile with privliged entitlement.\nDescription update",
                "privileged": true,
                "owner": {
                    "email": "[email protected]",
                    "type": "IDENTITY",
                    "id": "996737d8486a4a0887ac667b9923bed9",
                    "name": "toto toto (toto)"
                },
                "revocable": false,
                "endDate": null,
                "accessProfiles": [
                    {
                        "id": "6a33a77ff8c94d229ab1f1f38f254271",
                        "name": "DTR - AP 1",
                        "description": null,
                        "privileged": true,
                        "cloudGoverned": false,
                        "endDate": null,
                        "owner": {
                            "email": "[email protected]",
                            "type": "IDENTITY",
                            "id": "996737d8486a4a0887ac667b9923bed9",
                            "name": "toto toto (toto)"
                        },
                        "entitlements": [
                            {
                                "id": "f3468574e6f840a0a442da9599d15b88",
                                "name": "dtr-test-group",
                                "description": null,
                                "privileged": true,
                                "owner": null,
                                "attributeName": "groups",
                                "attributeValue": "64ef56fa-1919-4ced-9b51-ba376cf27340",
                                "sourceSchemaObjectType": "group",
                                "sourceId": "966376b439494b2f87554e28e414f565",
                                "sourceName": "Azure AD",
                                "sourceType": "Azure Active Directory",
                                "hasPermissions": false,
                                "isPermission": false,
                                "revocable": false,
                                "cloudGoverned": false,
                                "account": {
                                    "nativeIdentity": "4a5931bd-f7e0-4f00-959a-34382a859893",
                                    "disabled": false,
                                    "locked": false,
                                    "type": "ACCOUNT",
                                    "activityInsights": null,
                                    "description": null,
                                    "owner": null,
                                    "governanceGroupId": null,
                                    "id": "e38bfdafdca047f7ab32981f6fea6e41",
                                    "name": "[email protected]",
                                    "created": "2023-03-16T13:35:18.780Z",
                                    "modified": "2024-11-08T17:09:03.495Z"
                                },
                                "dataAccess": null,
                                "containsDataAccess": false
                            }
                        ],
                        "created": "2024-10-30T11:21:17.168Z",
                        "modified": "2024-11-08T16:41:11.571Z"
                    }
                ],
                "entitlements": []
            }
        },
        "identitySummary": {
            "id": "a1bb91eca12c4ff6b1d4a8eb49d4229e",
            "name": "Bakys Pyfedo",
            "identityId": "2c9180888168a7d501816ced361f6b9b",
            "completed": false
        }
    },
{},
{}
]

Hi Margo,

Thanks for the input.
I am trying to use the multiple reference method and it does work for “simple”’ items such as string or int but trying to pass an array of items seems to provoke an invalid JSON format somehow.

I pasted my input below

David

Hi David,
Since you have an array, you should remove the quotes around {{$.httpRequest.body}}
Try this:

{
"additionalData":"thisdata",
"body":{{$.httpRequest.body[*]}}
}

If you get the error ‘Unable to parse input as JSON, please ensure it is syntactically correct. (type: Error Parsing Input, retryable: false): invalid character ‘\n’ in string literal’, try removing the \n from your description on your entitlement.
Give this a try and let me know if it helps.

Inline variables that reference objects or arrays are not outputting valid json. They output a string representation of Golang maps and arrays. This is why you can use the “choose variable” to add the object to your request body, but not when using an inline variable. There is a ticket (PLTWRKFLW-1735) in the pre-release phase that will allow inline variables to reference objects and arrays as syntactically correct JSON.

Workflows now supports using objects and arrays in inline variables! To force objects and arrays to resolve to JSON instead of Golang strings, add a .JSON() to the end of your JSONpath. For example, $.trigger.identity is an object, and $.trigger.changes is an array. Adding .JSON() to each will make them print out their JSON representation instead of Golang representation.

{
  "identity": {{$.trigger.identity.JSON()}},
  "changes":{{$.trigger.changes.JSON()}}
}

Becomes this:

{
  "changes": [
    {
      "attribute": "department",
      "newValue": "marketing",
      "oldValue": "sales"
    },
    {
      "attribute": "manager",
      "newValue": {
        "id": "ee769173319b41d19ccec6c235423236c",
        "name": "ed.engineer",
        "type": "IDENTITY"
      },
      "oldValue": {
        "id": "ee769173319b41d19ccec6c235423237b",
        "name": "william.wilson",
        "type": "IDENTITY"
      }
    },
    {
      "attribute": "email",
      "newValue": "[email protected]",
      "oldValue": "[email protected]"
    }
  ],
  "identity": {
    "id": "ee769173319b41d19ccec6cea52f237b",
    "name": "john.doe",
    "type": "IDENTITY"
  }
}

Numbers, strings, and booleans do not need .JSON().

1 Like

Hi Collin,

This feature is new?
Do you know if this affects the behavior of workflows? I mean, I have workflows that use “[*]” with jsonpath to read arrays.

This will not affect existing workflows since you have to explicitly use the .JSON() function, which wasn’t available until now.

My ETS workflow that use “[*]” is broken. Yesterday they were working normally, today they are giving an error:

NOTE: There was no change in the configurations.

WorkflowExecutionFailed,“2024-12-12T22:08:11.490802044Z”,“{”“error”“:”“task failed: activity error (type: sp:external:http:v2, scheduledEventID: 41, startedEventID: 42, identity: 1@sp-workflow-worker-stg-us-east-1-cfd7dd48d-tqmdm@): Unable to parse input as JSON, please ensure it is syntactically correct. (type: Error Parsing Input, retryable: false): invalid character ‘7’ after object key:value pair (type: SyntaxError, retryable: true)”“}”

Please open a support ticket for this. I don’t see how this change would cause this as the behavior of existing workflows should be the same.

1 Like

Can you provide more information? What is the exact JSONpath you are using?

I have a workflow that uses ETS Dynamic Approval. I use a Sub Workflow that receives the information that is sent to the ETS. My Sub Workflow has a rule that needs to collect the description of the requested access.

$.trigger.requestedItems[*].description

This ETS was working normally, and about two days ago it started to give this error that I sent you in the chat. For now this error only persists in Sandbox, the same ETS in production is working normally.

Please follow Help - HTTP Requests failing with $getAccounts references due to escape characters appearing. Others are noticing strange behaviors as well.

1 Like

Thanks Colin, great news :slight_smile:

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