API Connector Error: "Unexpected token , in JSON"

I’m using the Bubble App Connector plugin to send data from one of my apps to another. The API request fails with this error:

“Error parsing request body: Unexpected token , in JSON at position 437”

It seems to be related to the meditation_source field, which is a list of text values. Here is an image of my backend workflow, I’m using:

Here is the configuration in the api connector:

I think I need to explicitly define this field as an array, and change the workflow expression. I’m unclear on exactly how should I properly format and send this data to avoid the JSON error?

Thanks in advance!

You need to show the value sent, not the expression. There is an issue in the value not the expression.

Expression suggests you are sending in a list of texts. Is the endpoint configured to receive a list for that parameter?

This will create an error for sure as you are encoding a list of text, each item, as json safe and not the whole thing. So you will have something like
"medication_source":"texta","textb","textc" … that is not a valid json. But to be able to help you, we need to know what the API expect… an array of string? in this case, you just need to add square brackets around it "medication_source":["texta","textb","textc"] but if you need something different, you may need to use :format as text instead.

Here is the data from the last error. The issue is with “desired_outcome_meditation”. I tried adding Json safe to the entire thing but that obviously didn’t fix it. What do I change the expression to?

The text is a list of text from an option set. How am I supposed to format it?

How do I check or modify the API’s expected input? Doesn’t the screenshot I sent in my original message, showing the API body from the connector, indicate that?

What the output expected by the API? any example? link to api doc? Actually, adding another formatted as json-safe probably set things wrong (but could have worked if the API expected a string). This is not what I believe and probably expect an array like I’ve suggested in my previous post.

What did you sent when you initialized the call in API Connector?

I’m not sure I understand. I recorded a 1 minute video showing the set up. Any guidance would be greatly appreciated!

It doesn’t help. Without knowing what the API expect (array, string, object…) I cannot tell you exactly what you need to do.
Could be easy as adding [ square bracket] around (if the api expect an array of string) or more complex to use :format as text on the list or this could be :join with , and :format as json-safe if this expect a string.

So my question is what did you provide in API Connector for this field when you initialized it? Or API Doc that can show what API expect there…