I have one flow which is getting the messages from the Crisp chat via Api for that i used
this endpoint “/messages?limit=20&order=desc“ and i m getting the response in output => body => data => collections now i want to send this all collections as one string in HubSpot notes so for that i was trying to use “create a note“ module which is already provided but I m facing scope permission issue so i try to make API call and currently i am using “http make request” module and in this i have set all the require properties and timestamp etc. but when i get the collections after that sending all that data in one string i used “iterator” module after that i used “text aggregator” module to format that data and sending into one string
and this is formatting the text as well but when i used this in my final module for making API call i am facing this error
Error: 400 Bad Request
{“status”:“error”,“message”:“Invalid input JSON on line 3, column 820: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value”,“correlationId”:“691dc311-0000-0000-2b73-8510d2c51ab0”}
You can use the replace() function to escape special characters. Check your incoming string for what specifically is breaking the JSON and escape it. Or you can try something like this.
This is NOT sufficient to convert text to an escaped (safe) JSON string.
Escaping strings before mapping into another JSON string
Most of the time, you cannot directly map variables containing text content into another JSON string without escaping them, as the variable might contain special characters that are reserved. Special characters in JSON needs to be escaped (encoded) as a “literal” character, otherwise they make the whole JSON invalid when you map the variable value when creating another JSON string.
You can escape string variables by passing the text into the “Transform to JSON” module. You can also build a valid JSON string by using a Data Structure with the “Create JSON” module. Then, you can map the output of the Transform module into another JSON string, or simply use the whole output of the Create module.
Note:
When using the “Transform to JSON” module, the output should already contain the double quotes " " around your text, so when you map this output into your JSON, you should not need to wrap another pair of double quotes around it.
Alternatively, you can use the built-in function replace to replace those special characters with their escaped versions. To do this, simply paste this into the field, and replace the 1.text variable: