12-10-2021 11:56 AM
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.
Solved! Go to Solution.
12-12-2021 02:12 AM
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.
12-12-2021 02:12 AM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide