API Connector is not recognizing the object returned as valid json object

Hello Everyone, I am using bubble’s backend workflows to make API call to open AI and getting structured response(tool calling) or simple respone depending on prompt as then calling that backend workflow from API connector.


But when I am calling it from API connector it’s working fine for simple responces but it’s giving Invalid Json object error in case of object return.
.
but the data looks like this when used thunder client

Can anyone help me with this?

@wajahatpunk I personally don’t like the inconsistencies that formatted as JSON-safe gives me in my experience working with it.

parameter 1. Since “is_question” is a simple yes or no value, remove “formattd as JSON-safe” and ensure the content inside the formatted as text is quoted (i.e “yes” or “no”)

parameter 2. …

parameter 3. “text” is a text value, remove “formattd as JSON-safe” here and quote the result of step 1, so you should have “text”: “Result of step 1…choices:first item’s message content”

parameter 2. test parameter 1 and parameter 3 above while using a static text for “questions”: “null”, if it works, then you can insert your current dynamic value in the second parameter.
after the :formatted as text in the second parameter, add a find a replace (check the regex pattern box, regex pattern value = \n, replace value = a single space (you can also use \n, but start by using a single space to be safe).)

Let us know how it goes.

Thanks for taking out time to explain this.
The problem was with second entry in object (questions). It was a complete object itself containing the questions so i removed the curly brackets using regex and it’s working now


This topic was automatically closed after 70 days. New replies are no longer allowed.