cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1262
Views
15
Helpful
1
Replies

UCCX Send json double quotes in REST request

samson.kareem
Level 1
Level 1

Hi All,

We are trying to send a REST API POST request containing JSON in the body of the request. We have formatted the JSON into a string`in the Body of the Make REST step as per below. The issue is we cannot remove the "\" that escapes the quotes in JSON. We cannot use single quotes as this is not accepted as valid JSON.  Does anyone know of a way round this other than using custom Java?

 

The string is similar to the below

u"{\"skill\": \" + sSkill + \\" , \"phoneNumber\": \" + sCaller_id + \", \"handoffId\": \"+ sHandoff_id + \"}"

 

We have tried using regex to replace strings and concatenating but the "\" is always retained when doing a reactive debug.

 

 

1 Accepted Solution

Accepted Solutions

samson.kareem
Level 1
Level 1

It turns out that UCCX IS actually escaping the quotes correctly in the POST message that is sent out. The issue is that this does not show in reactive debug in the Script Editor.

 

Once I saw what was being received, I could see what the issue was with the JSON formatting. In case this helps someone I had to to send a JSON string with a mix of static text and UCCX variables as a sequence of strings as per below:

 

u"{\"static\":" + u"\""+ variable + u"\""+ u"}"

 

The pieces of the puzzle are the opening JSON brackets and key, open quotes for the variable (escaped), the variable, the close quotes (escaped) and the close brackets. The last two could be part of the same string but it's easier to read this way when you have several variables.

View solution in original post

1 Reply 1

samson.kareem
Level 1
Level 1

It turns out that UCCX IS actually escaping the quotes correctly in the POST message that is sent out. The issue is that this does not show in reactive debug in the Script Editor.

 

Once I saw what was being received, I could see what the issue was with the JSON formatting. In case this helps someone I had to to send a JSON string with a mix of static text and UCCX variables as a sequence of strings as per below:

 

u"{\"static\":" + u"\""+ variable + u"\""+ u"}"

 

The pieces of the puzzle are the opening JSON brackets and key, open quotes for the variable (escaped), the variable, the close quotes (escaped) and the close brackets. The last two could be part of the same string but it's easier to read this way when you have several variables.