There is an API that has been customized for me.
There is a JSON format that I have to pass in a POST request.
I set up a Call API (Data type) and during initialization I insert data, according to a certain structure, the text of my JSON example.
The initialization passes, a picture file is returned back to me.
Everything works.
Next, I make a dynamic parameter in Call API through the value
In Workflow I try to write in the field of type “file” the result of CallAPI work through “Get data from an external API”->saved to S3, passing as a parameter the text in the parameter, which I used during CallAPI initialization.
But in this case I get an error that “Unexpected character when reading in JSON” error was found.
That said, I immediately copy my text sent in , paste it into the call initialization and it works.
I can’t understand what the problem is, what kind of unmoved character is passed to JSON.
If you want to post json here, use ``` around your text. It will give:
Text
For your issue, you will need to use :formatted as json-safe on some of your string because you have characters that will create issue in JSON. when you use :formatted as json-safe, this will also add the double quotes around your string. So you may need to remove it in API Connector
I’m trying to write into the field of file type what comes in the response to the API request.
The file of type PDF is returned and I need to replace its name.
However, the name is not replaced
You cannot format all the arbitrary text that contain the whole JSON. You need to format specific part of it
Let’s say: {"parameter":"text"that"need encoding"}
You will set {"parameter":inputvalue:format as json safe}
The output will be: {"parameter":"text\"that\"need encoding"}
It’s hard to know but your json is not correctly encoded for sure. You need to inspect your json and find where is the error. jsonlint can help you inspect the json