cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
656
Views
0
Helpful
6
Replies

UCCX (ver. 12.5) script Make Rest Call with POST and Body request

ledj
Level 1
Level 1

I'm working on a uccx script that initiate Make Rest Call with Post and Body content to pass Metadata. I use a variable to place my syntax i test working successfully in Postman. However, when im about to put in on the uccx variable i declare in the script im getting error "Unable to Parse expression; Couldn't repair and continue parsing on toke #ID 'acdServerId'(line:1, col:4). Take note i followed recommended from other forum using single quote instead of double quote but im getting 400 bad request. 

Hoping someone can share insight how i can properly correct the syntax.

Postman Request Body - working successfully.

"{"acdServerId": "7", "acdId": "variable1", "metadata": [{"name": "queue-name-key", "value": "variable2"}]}"

UCCX script - getting error

 

ledj_2-1685001268415.png

 

ledj_1-1685001053167.png

 

ledj_0-1685001014322.png

 

6 Replies 6

If you pass the string directly without using a variable does it work?

david

It works if you pass the string, but my challenges is I have to pass dynamic variable to the request body.

Ok, this is good though that means that your request step is correct and you just need to get the format of the string. Can you post the variable string you're trying to use that fails?

david

I tried this syntax where Agent and Queue are the dynamic variables
u"{\"acdServerId\": \"20\", \"acdId\": agent, \"metadata\": [{\"name\": \"queue-name-key\", \"value\": Queue}]}"

Ok so I've done something very similar for SFDC.

1. Have a string variable which captures the format of your JSON I call mine caseTemplate. U"{\"BotId__c\":\"4600\",\"Status\":\"New\",\"CallType__c\":\"Equipment\",\"RecordTypeId\":\"0121U00GJ\",\"Origin\":\"IVR\",\"CSTProblemReported__c\":\"Move On Location\",\"AccountId\":\"%1s\",\"Description\":\"David Macias UCCX\",\"Subject\":\"Move On Location\",\"Priority\":\"3\"}"

Notice the %1s after AccountId, I'll be setting this dynamically later.

2. Use a Set step to set a string with your dynamic varialble. String.format( caseTemplate, new Object[] { accountId } )

3. The end result is: "{\"BotId__c\":\"4600\",\"Status\":\"New\",\"CallType__c\":\"Equipment\",\"RecordTypeId\":\"0121U00GJ\",\"Origin\":\"IVR\",\"CSTProblemReported__c\":\"Move On Location\",\"AccountId\":\"123456\",\"Description\":\"David Macias UCCX\",\"Subject\":\"Move On Location\",\"Priority\":\"3\"}"

I hope this helps.

david

I saw some discussion in the Collaboration -> Contact Center group about a similar issue. This thread talks about creating a JSON document and passing that to ServiceNow, so that might help you.

https://community.cisco.com/t5/contact-center/json-in-uccx-script/td-p/4844756