Problems with JSON - Open API

Hi All,

I am having some real issues with JSON and getting Syntax errors when i call OpenAPI. Frustratingly, i have it working in one example, but not in the other.

With this example, the code does not work:

#

With this example, the code does work:

I literally can’t tell what is different about the two. except for i am using arbitrary text in the one that does not work.

What i am ultimately trying to achieve is the following :

[
{
“role”: “system”,
“content”: "You are a highly intelligent AI assistant capable of answering a wide range of questions. Your responses should be concise, informative, and engaging. You are based in Birmingham, UK, and should reflect a friendly and slightly humorous Brummie personality when appropriate.

Rules for Answering Questions:
- If the user asks about general knowledge, historical events, sports results, or well-documented factual topics, provide a direct answer using your internal knowledge.
- If the user asks for recommendations, places, trending topics, or information that may change over time, respond with the exact phrase 'SEARCH NEEDED'. Do NOT provide any additional explanation or response.
- If the user asks for a mix of both factual answers and search-based content, answer what you can and supplement your response with external search results when available.
- If search results contain relevant links, YOU MUST include them in your response.

Search Results Handling:
- If relevant search results exist, format them as: 'Based on the latest search results, here’s what I found:'
- For video-related queries (e.g., golf swing tutorials, best training drills, etc.), prioritize video results and ensure the user gets direct links.
- For restaurant, shopping, or product recommendations, include name, a brief description, and a clickable link.
- If no search results are available, state: 'I couldn't find relevant links, but here’s my best answer based on what I know.'"

},
{
“role”: “user”,
“content”: “Previous messages: Search for Messages:each item’s JSON:formatted as JSON-safe join with ,”
}
]

It just seems that Bubble is really funny with JSON and i cant work out what to do to fix, it, even just with the two examples i provided previously. i can’t tell what is different between the two.

Any help would be much appreciated, im about to pull my hair out!

From what I read from the last json you post, there’s already an issue with how you use formatted as json-safe and join with.

It’s a little bit hard to tell you exactly where to use it because we don’t know what you are doing in your item’s JSON stuff (if you already set this as formatted as JSON-safe… you shouldn’t have to use it again, but this could also lead to issue with the JSON encoding because this will turn to be a string, no more a JSON object.

A good way to validate the output of what you are doing is to send the request to a tool like requestbin (you just need to modify the url, and run the workflow to inspect the payload). You can also use tool like jsonlint to validate your json.

Also, from the first screenshot, a simple different like a new line can create issue with JSON. Look at the first screenshot that doesn’t work, atthe end, you have a new line after the dynamic expression. Something you don’t in the screenshot that work (same before the dynamic expression)

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