Passing a JSON Value to a JSON API Request

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Palo Alto Networks Approved
Palo Alto Networks Approved
Community Expert Verified
Community Expert Verified

Passing a JSON Value to a JSON API Request

L2 Linker

Hi All, I have faced one issue while sending a API call to IVANTI. I need to call one value into this request as below

{
"OrgUnitLink": "${org}",
"Symptom": "${body}",
"Subject": "${incident.labels.Email/subject}",
"Source": "Email",
"Status": "Submitted"
}

${org} gets passed without an issue when I call it since the value is like asda232adadf334d 

But when I call an email body(${body}) it gets screwed up since the final call looks like below,

Json.PNG

I know that the error is coming because JSON need some characters escaped. But I have no idea how to do this. Any help would be appreciated.

Ivanti.PNG

 

2 REPLIES 2

L6 Presenter

As your issue is so specific and I do not have this integration or I have not had any issue with json escape characters I can give you the advice to search scripts that have json in the name like https://xsoar.pan.dev/docs/reference/scripts/json-unescape as this sounds the reverse of what you want but you can reverse engineer the script 🙂

 

Other scripts to look:

 

https://xsoar.pan.dev/docs/reference/scripts/ignore-fields-from-json

 

https://xsoar.pan.dev/docs/reference/scripts/dump-json

 

https://xsoar.pan.dev/docs/reference/scripts/parse-json

 

https://xsoar.pan.dev/docs/reference/scripts/load-json

 

 

There are many more.

L2 Linker

Created one of my own scripts to remove conflicting characters. It looks a bit ugly after formatting but better than nothing 🙂 

 

function removeJsonEscapableChars(str) {
  const escapableChars = /\\["\\\/bfnrt]/g;
  return str.replace(escapableChars, '');
}
var body = args.value;
body = JSON.stringify(body);

setContext(args.key, removeJsonEscapableChars(body));
  • 1451 Views
  • 2 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!