Issue when raising ticket to Servicenow through workflow

Hi All,


When I use $.hTTPRequest.body[*].attributes.displayName in the “Send Email” action, I can see the displayName list in the sent mail. However, when I try to use the same in the HTTP action while raising a ticket in ServiceNow, like this: {{$.hTTPRequest.body[*].attributes.displayName}}, I encounter the following error:

“Unable to parse input as JSON, please ensure it is syntactically correct. (type: Error Parsing Input, retryable: false): invalid character ‘\’ looking for beginning of object key string”

Complete w/f:

{
	"name": "Search based workflow",
	"description": "Search based workflows for the Entitlement and Account aggregation failure , Identity exception",
	"modified": "2024-05-27T16:12:06.177904167Z",
	"modifiedBy": {
		"type": "IDENTITY",
		"id": "2cxxxxxxxxxxxxxxxxxxxxx54",
		"name": "vsxxxxx6"
	},
	"definition": {
		"start": "HTTP Request",
		"steps": {
			"End Step - Success": {
				"description": "Success",
				"displayName": "",
				"type": "success"
			},
			"HTTP Request": {
				"actionId": "sp:http",
				"attributes": {
					"authenticationType": "OAuth",
					"jsonRequestBody": {
						"indices": [
							"identities"
						],
						"query": {
							"query": "processingState:ERROR"
						}
					},
					"method": "post",
					"oAuthClientId": "e9exxxxxxxxxxxxxxxxxxxx8b2",
					"oAuthClientSecret": "$.secrets.127947xxxxxxxxxxxxxxxx0",
					"oAuthCredentialLocation": "oAuthInHeader",
					"oAuthTokenUrl": "https://cxxxxx4-dev.api.identitynow.com/oauth/token",
					"requestContentType": "json",
					"requestHeaders": {
						"Accept": "application/json"
					},
					"url": "https://cxxxxx4-dev.api.identitynow.com/v3/search"
				},
				"displayName": "",
				"nextStep": "Send Email",
				"type": "action",
				"versionNumber": 2
			},
			"HTTP Request 1": {
				"actionId": "sp:http",
				"attributes": {
					"authenticationType": "OAuth",
					"jsonRequestBody": "{\\\"assignment_group\\\":\\\"Access-Governance-L2\\\",\\\"business_service\\\":\\\"Identity Governance and Administration (IGA) Service\\\",\\\"caller_id\\\":\\\"abdxx20\\\",\\\"category\\\":\\\"software\\\",\\\"cmdb_ci\\\":\\\"SailPoint (Dev) IdentityNow\\\",\\\"contact_type\\\":\\\"Alert\\\",\\\"description\\\":\\\"There has been an error in Identity processing state {{$.hTTPRequest.body[*].attributes.displayName}}\\\",\\\"impact\\\":\\\"2 - medium\\\",\\\"short_description\\\":\\\"Please Ignore this incident, this is part of Sailpoint APIGEE Testing\\\",\\\"subcategory\\\":\\\"applications\\\",\\\"urgency\\\":\\\"2 - medium\\\",\\\"work_notes\\\":\\\"Auto Alerts Created for Failures\\\"}",
					"method": "post",
					"oAuthClientId": "tmxxxxxxxxxxxxxxxQT",
					"oAuthClientSecret": "$.secrets.fxxxxxxxxxxxxxxxxxxxxa",
					"oAuthCredentialLocation": "oAuthInBody",
					"oAuthTokenUrl": "https://hoooo-api-dev.apigee.net/oauth/v2/client_credential/accesstoken",
					"requestContentType": "json",
					"requestHeaders": {
						"x-apikey": "txxxxxxxxxxxxxxxxxx3QT"
					},
					"url": "https://hoooo-api-dev.apigee.net/eap-servicenow-mgmt/v1/servicenow/incidents"
				},
				"description": "Create Incident for the Failed Request",
				"displayName": "",
				"nextStep": "Send Email 1",
				"type": "action",
				"versionNumber": 2
			},
			"Send Email": {
				"actionId": "sp:send-email",
				"attributes": {
					"body": "<p>Dear Team,</p>\n\n<p>We have detected Error in the identities. Below are the reports:</p>\n\n<h3>Identities in Error state</h3>\n<ul>\n    <li>${name}</li>\n</ul>\n\n<p>Please investigate and take necessary actions to resolve these issues promptly.</p>\n\n<p>Best regards,</p>",
					"context": {
						"name.$": "$.hTTPRequest.body[*].attributes.displayName"
					},
					"recipientEmailList": [
						"[email protected]"
					],
					"subject": "Identities with Error"
				},
				"displayName": "",
				"nextStep": "HTTP Request 1",
				"type": "action",
				"versionNumber": 2
			},
			"Send Email 1": {
				"actionId": "sp:send-email",
				"attributes": {
					"body": "Dear {{$.getIdentity.attributes.displayName}}, <br>\n\nPlease note that your recent SailPoint request has failed. We have automatically created a ticket on your behalf. The ticket number is {{$.hTTPRequest.body.result.number}}.<br>\n\nRegards,<br>\nSailPoint Service Team",
					"context": {},
					"recipientEmailList": [
						"[email protected]"
					]
				},
				"description": "get incident id",
				"displayName": "",
				"nextStep": "End Step - Success",
				"type": "action",
				"versionNumber": 2
			}
		}
	},
	"creator": {
		"type": "IDENTITY",
		"id": "4xxxxxxxxxxxxxxxxxxx1",
		"name": "hxxxxx4"
	},
	"trigger": {
		"type": "SCHEDULED",
		"attributes": {
			"cronString": "0 * * * *",
			"frequency": "cronSchedule",
			"timeZone": "Asia/Calcutta"
		}
	}
}

Please let me know if there is any findings!

Thanks,
HArish G

Hi @harishhaleon,

I see that your code is not having “*” in the request body. But as per mentioned mapping it should have *.

Check once this is a typo or it is missing.

Thanks

@ashutosh08 - Sorry, I missed it while pasting but I am trying with * only.

@sharvari - I have seen your article. Do you have any inputs?

When enclosing workflow variables in quotes, most of the times they don’t get substituted.

Regards,

Sharvari

This is a known issue with workflows with an engineering ticket (PLTWRKFLW-1735). Inline variables do not resolve arrays or objects as proper JSON. They resolve them as Golang maps and arrays. The Send Email body is just text, so it doesn’t complain about this, but if you try to reference an array or object in an HTTP Request body where it expects JSON, it will fail with that error. There is currently no workaround to this. You can’t use inline variables to reference arrays or objects in an HTTP Request body. You can only use inline variables to reference single values, like a string, number, or boolean.

1 Like

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