cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
744
Views
15
Helpful
4
Replies

JSON Body - adding variable in Rest Call

asegal
Level 1
Level 1

I am doing a Make REST Call I am having trouble getting the SSN variable into the string . So my app ask for the numberSS  as a Get Digit String and that works perfect as when I run in Debug I see the variable populated. 

Now here is the body 

u"{\"callname\":\"JNSPBILL\",\"ssn\":\+ numberSS\,\"db_nbr\":\"488\"}"

Now when I run the debug the word numberSS  is still in the body and then I get a not on file and the ssn is all zeros .

When I set the body to a parameter in my system and set it up as this

u"{\"callname\":\"JNSPBILL\",\"ssn\":\"111222333\",\"db_nbr\":\"488\"}"

it works fine.  So, my question is the proper way of inserting a variable into the string prior to sending it. 

Attached is the Make REST Call screen shot. I know the rest call works its the variable that is the issue 

Thanks in advance

Allan

1 Accepted Solution

Accepted Solutions

asegal
Level 1
Level 1

Thanks to all here as I am new to the Cisco world coming from Avaya and Aspect and other switches. Our issue was we are going from UCCX platform to a Linux platform and all these different rules on double quote's and backslashes. What we was set up the string to accept the variable then built around it until the JSON parser accepted it . We used Debug and evaluate to figure it out . the result looked like this below. numberSS is the variable and it works fine.

I truly appreciate all the assistance and look forward to more interactions 

Allan

U"{\"callname\": \"JNSPBILL\",\"ssn\": " + numberSS + U",\"db_nbr\": \"488\" }"

    

View solution in original post

4 Replies 4

Jonathan Schulenberg
Hall of Fame
Hall of Fame

A variable name will be treated as text characters if within double quotation marks. You will need to break the string into pieces and concatenate it together. For example, “foo” + stringVariable + “bar” 

Jonathan is 100%. Here's an example in JS doing a very similar thing.

var delta = nowDate.getTime()-callStartDate.getTime();
ctrString = '{"CALABRIO_REDACT":"[0000,'+delta+']"}';

david

asegal
Level 1
Level 1

Thanks to all here as I am new to the Cisco world coming from Avaya and Aspect and other switches. Our issue was we are going from UCCX platform to a Linux platform and all these different rules on double quote's and backslashes. What we was set up the string to accept the variable then built around it until the JSON parser accepted it . We used Debug and evaluate to figure it out . the result looked like this below. numberSS is the variable and it works fine.

I truly appreciate all the assistance and look forward to more interactions 

Allan

U"{\"callname\": \"JNSPBILL\",\"ssn\": " + numberSS + U",\"db_nbr\": \"488\" }"

    

CCX is basically Java (not JavaScript). The CRS Editor and steps in the palette are a GUI abstraction/representation of Java programming. The expression editor lets you write snippets of real Java code though; heck you can even install custom Java classes on the server when necessary. When in doubt how to do something custom in the CRS Editor, I just Google for how to do it in Java; there are usually a bunch of results. In this case, "how do I concatenate strings in Java" would get you an answer. Just be careful to use answers that apply to the Java version appropriate to your CCX version; it's listed in the compatibility matrix.