HTTP Request json body not working with inline variables

Hi,

I’m trying to create a ticket in ServiceNow. I’ve tried using a json request body in an http request step, the ticket is created in ServiceNow. But the json request body is not showing properly the values of the inline variable attributes. Let me show this:

My http request step configuration:

My json request body:

{
	"u_actiontype": "Transfer",
	"u_department": "{{$.getIdentity.attributes.department}}",
	"u_linemanager": "{{$.getIdentity1.attributes.displayName}}",
	"u_jobfunction": "{{$.getIdentity.attributes.jobtitle}}",
	"u_location": "{{$.getIdentity.attributes.location}}",
	"u_enddate": "{{$.getIdentity.attributes.endDate}}",
	"u_firstname": "{{$.getIdentity.attributes.firstname}}",
	"u_lastname": "{{$.getIdentity.attributes.lastname}}",
	"u_sfid": "{{$.getIdentity.attributes.sfId}}",
	"u_transferdate": "{{$.getIdentity.modified}}"
}

What is being created on ServiceNow for this ticket:

In theory everyhting seems correct for me, and regarding to a similar topic with the same issue->

The solution provided should work, but it isn’t.

Further more, I’m having the exact same problem with the Manage ServiceNow Ticket step when tryng to create a ticket.

My Additional Fields:

u_actiontype:Transfer
u_department:{{$.getIdentity.attributes.department}}
u_linemanager:{{$.getIdentity1.attributes.displayName}}
u_jobfunction:{{$.getIdentity.attributes.jobtitle}}
u_location:{{$.getIdentity.attributes.location}}
u_enddate:{{$.getIdentity.attributes.endDate}}
u_firstname:{{$.getIdentity.attributes.firstname}}
u_lastname:{{$.getIdentity.attributes.lastname}}
u_sfid:{{$.getIdentity.attributes.sfId}}
u_transferdate:{{$.getIdentity.modified}}

What is being created on ServiceNow for this ticket:

I’ve tried multiple combinations to get a workaround for this issue, but no luck so far.

Any help would be appreciated. Thanks.

@franciscojoserodrig1 , Inline variable were working , I noticed after december 1st it stopped working in http body.We also raised a ticket regarding that. For a quick workaround try to create json like this

\"u_transferdate\": \"{{$.getIdentity.modified}}\" 

Thanks @gourab, I’ll try this ASAP.

This is my request body applying your possible workaround @gourab

{
	\"u_actiontype\": \"Transfer\",
	\"u_department\": \"{{$.getIdentity.attributes.department}}\",
	\"u_linemanager\": \"{{$.getIdentity1.attributes.displayName}}\",
	\"u_jobfunction\": \"{{$.getIdentity.attributes.jobtitle}}\",
	\"u_location\": \"{{$.getIdentity.attributes.location}}\",
	\"u_enddate\": \"{{$.getIdentity.attributes.endDate}}\",
	\"u_firstname\": \"{{$.getIdentity.attributes.firstname}}\",
	\"u_lastname\": \"{{$.getIdentity.attributes.lastname}}\",
	\"u_sfid\": \"{{$.getIdentity.attributes.sfId}}\",
	\"u_transferdate\": \"{{$.getIdentity.modified}}\"
}

But with that, the json body is not valid:

Could you @colin_mckibben please provide feedback on this topic/issue?

@franciscojoserodrig1


"{\"u_actiontype\":\"Transfer\",\"u_department\":\"{{$.getIdentity.attributes.department}}\",\"u_linemanager\":\"{{$.getIdentity1.attributes.displayName}}\",\"u_jobfunction\":\"{{$.getIdentity.attributes.jobtitle}}\",\"u_location\":\"{{$.getIdentity.attributes.location}}\",\"u_enddate\":\"{{$.getIdentity.attributes.endDate}}\",\"u_firstname\":\"{{$.getIdentity.attributes.firstname}}\",\"u_lastname\":\"{{$.getIdentity.attributes.lastname}}\",\"u_sfid\":\"{{$.getIdentity.attributes.sfId}}\",\"u_transferdate\":\"{{$.getIdentity.modified}}\"}"

can you try this and let me know if it is working?

3 Likes

Thank you so much @gourab , it is working!

1 Like

I’m having the same problem, and my request body includes jsonPath expressions that include quotes so the solution shown above is not working. Are there any plans to fix this? It looks like a regression, and most of the other fields I’ve used in Workflows don’t require us to escape or URL-encode special characters.

I have this working, you basically need to escape the entire request body in a similar way to how you need to escape the ‘script’ value for connector rules before uploading them.

However, this is definitely a bug:

  1. Open workflow with HTTP Request JSON Body, supply fully-escaped body in JSON request body
  2. Save workflow and test, confirm the body in step 1 works
  3. Re-open workflow and look at HTTP Request JSON Body field from step 1

Expected results: it should have exactly what I put in the box in step 1 so I can edit it in the tool without breaking it.
Actual results: the Request Body field shows the fully-unescaped version of the request, and making any changes to it in the tool and saving will break the workflow because it’s no longer escaped

1 Like