Hello
I am working on a flow to generate audio with an HTML request taking the script from my database. Once I run the worflow I found the error 422.
Any suggestion how to solve it?
Hello
I am working on a flow to generate audio with an HTML request taking the script from my database. Once I run the worflow I found the error 422.
Any suggestion how to solve it?
Welcome to the Make community!
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:
{{ replace(replace(1.text; "/([""\\])/g"; "\$1"); "/\r?\n\r?/g"; "\n") }}
For more information on JSON and escaping JSON strings, see:
Hope this helps! If you are still having trouble, please provide more details.
— @samliew
P.S.: investing some effort into the tutorials in the Make Academy will save you lots of time and frustration using Make!