OpenAI API Call Not Running with " when formatted as json safe

I’m setting the input value to formatted as json safe but it’s still not running if quotation marks (") are in the input.

I’ve looked at the other answers but can’t work it out. Thanks in advance.

What does your API call setup look like?

1 Like

Is this what you need @christo1 ?

You cannot use encode as json-safe on a part of the value. All the value need to be encoded as json-safe because this function add doubles quotes around the whole string. So remove all the content value including double quotes, put this in arbitrary text, fill the placeholder with dynamic text, and apply the format as json on the arbitrary text, not on each part. You can probably remove \n and replace them by real newline

2 Likes

As Jici said. What I would do is Multiline Guest Review’s Value.Find and replace

Then find " and replace with a space. It will fix it if they use ". You can find and replace any other characters that break the API as well this way without having to redo it all. JSON safe does capture more issues but will require more work to implement if you’re in a hurry. For me " always breaks things, so is the most common issue you’ll encounter.

2 Likes

Thanks everyone. Find and replace was easy enough to implement and fix the issue

2 Likes

But like @christo1 said, you could face some issues with other characters that must be encoded + you are loosing some key information by removing all the double quotes from the string (but this depend of what you are doin with the content…). Honestly, you should use the right function for this kind of case, and for that, it’s encoded as json-safe.

2 Likes

Thank you. Could you please help me understand what is the “right function” I should be using?

I know the find and replace is work around. Can you help?

It’s all in my previous post. :formatted as json-safe is the function, but you need to do a little more work on that by moving all the value to the arbitrary text first.

2 Likes

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