List of numbers being passed as string

I need to pass a list of numeric ID’s to Xano, which is expecting a list of numbers. The numbers on bubble are being stored in a custom state list of numbers. I’ve tried passing the list through the api as “Custom States List of Numbers” as well as “[Custom States List of Numbers]” as well as “[Custom States List of Numbers:format as text(this number, “,”)]”. Every single variation ends up being passed to Xano as a string. What can I do to correct this behavior?

That’s because those are all strings.

Pass it as an array.

i.e.

[1, 4, 11, 14, 26] etc.

Assuming you are using an API configured in the API Connector - on your action, simply add square brackets (typed manually) around your dynamic value, formatted as text. This would look like this:

There’s a bunch of other ways you could pass the data out, but you get the point. You just need to change the “drpKeyFeatures value” in my example with your custom state, add the “format as text” with the , as a delimeter, and add square brackets around the whole thing. Xano won’t worry about an empty set of square brackets either if the custom state is empty. My entire app has a Xano backend, so I use this approach regularly.

I’m not actually wrapping the expressions in " " 's. On hover, the expressions say they are a list of numbers (except for the last one).

This results in the following error.
{“code”:“ERROR_CODE_INPUT_ERROR”,“message”:“Value is not a valid integer.”,“payload”:{“param”:“state_id”}}

this is the input:
state_id:

[20,21]

,

The xano set up.

You need to add the “format as text” to the end of the state, as per my above example.

Most recent request.


I have tried your method prior to this. I usually use Eli’s xano connector plugin, but for returning a CSV file I’m using the actual api connector plugin for this specific call. I read somewhere that bubble automatically wraps values in “”, is this true?

No - this is all down to configuration in the API connector. In the JSON body, make sure you don’t have quotes around the dynamic values (the green triangle brackets), like below:

In your API action, if you are dealing with any string type - use “formatted as json-safe” after each parameter, and it will automatically stringify any text (this function basically escapes any special characters and adds quotes around the final value).

You only need “formatted as json-safe” around string values, but for any numeric value just pass it without json-safe. For true/false you will need “formatted as text”, since bubble will send a “yes/no” instead of boolean. true/false or 1/0 can be sent to a boolean value without issue, so no json-safe needed either.

I will also add, I created a Xano Plugin of my own that was (many versions back) based off the Xano Connector plugin - so I can confirm your use case 100% works with Bubble and it doesn’t cause issues with automatically converting values to strings.

This was my next step. I’m not using the json body for my parameters.
Gonna change it to a POST request and try your suggestion now. I’ve gotten this to work in other places. I utilize this same input of values for a search function and it works just fine, but for my export function it’s giving me this problem. I’ll let you know if this update works.


This is resulting in a:
There was an issue setting up your call.

Raw response for the API
Status code 500
{“code”:“ERROR_FATAL”,“message”:“Error parsing JSON: Syntax error”}

Based on your screenshot, I assume that was when you tried to initialise the call? If so, you need to manually quote the data sent in that request if it’s a string, as it’s otherwise not valid JSON. You can always use various online services or local tools to validate your JSON is correct (e.g. notepad++)

So simply add quote marks around each of those pieces of data you have entered into the “value” fields (since they are all strings).

Dude, this thing is all messed up and I don’t know where to begin. I’m no newbie to linking my app up with xano, I probably have well over 100 various queries and actions throughout my app. With my current iteration for this API, bubble is sending over the data per the logs:

And here is what Xano received:

And it gave me an output!! IDKWTFIGO…I’ve signed up for an office hours with them on tuesday, but if you have some time I’d appreciate if I could get a second pair of eyes on it. Shoot me a DM if you don’t mind helping out.

Can you screenshot the full API config (just mask out the URL and any auth tokens for security)? Also the latest version of the action you are sending to the API.

I’ve seen all manner of issues with APIs - I have a feeling I know where your issue is occurring.

Let me make a loom and I’ll include screen shots.

1 Like

Before you do that - main thing I noticed is that you have put “submitted_from” and “submitted_to” as parameters (instead of in the body).

Is this a data source (e.g. are the parameters only for displaying in the app), or is it a data change? In technical terms - is it a create, read, update or delete? If it’s a create/update/delete - use the appropriate verbage in the API configuration (e.g. POST/PUT/PATCH/DELETE).

If this is for displaying data in the app (e.g the parameters are for filtering), use a GET, and after the URL - specify “data”. If you are using the GET - use the Xano Connector plugin, and set it to the data type you created in the API Connector. You won’t need the workflow action in this case.

I had assumed since you had an API action, you were making a change to the data, but if you’re expecting a full list of response data to populate an RG - it’s a different approach to get this working.

I’m returning a CSV, so I guess it would be a GET? Which IS how I had it set up originally. But using a GET method doesn’t give you access to the JSON body. The expected return data is a file. I actually have multiple CSV exports working just fine, but since I’ve tried updating the queries for the export to include multiple results based on an array of inputs, everything has fallen off the rails.

I can see where the issue is I think.

  1. This looks to be a “GET” use case. How have you been retrieving data so far, or is this the first “query”? I would use the Xano Connector for this.

  2. Assuming this is true, update the API to GET and the API connector config. Next to the URL, change the drop-down from “Action” → “Data”. Each input to your API becomes a parameter.

  3. For any input to the API that allows NULL, check “Allow Blank” and “Optional”.

  4. To initialise the call, create a full JSON body structure and pass the required values to the API, with quotes for any string values.

  5. Add the “Xano Connector” plugin if you haven’t already, and add a “Xano Query” element to the page (assuming this API returns a list of data in an array).

  6. Set the Xano Query element to the correct data type, and put the JSON structure you used to initialise into the Xano query element. Replace any “values” with dynamic values, including the JSON formatting etc., similar to below:

  7. Set the data source of any RGs or groups to the Xano Query element.

On the data in the Xano UI - white values mean a string (i.e. “null”), but grey values are actually null (i.e. null).

The reason you were getting errors with the dates is that the format is not one that Xano recognises. You might notice in my above screenshot, I pass the date format differently to Xano. The format Xano recognises is:

You might also note from the above how I pass arrays and where I use “format as text” and “format as JSON-safe”.

Forgot to mention, I’m stuck on meetings all day so won’t have time to jump on a call unfortunately - but I think this is actually a fairly straightforward issue to resolve.

You have a lot of errors.
Example… sending empty array will not work just by adding allow blank because if you have set double quotes around it, it will send “null” and not null.
An array of number is [ 1,2,3,4] , no doubles quotes around them, so no use of formatted as json. A date format depend of the API you are calling because there’s no “date” type in JSON. A date is sent as a string like any other string. Also, don’T send parameters (if not querystr checked) + JSON body. This will create issue with your call

Not related to action VS data.

Not valid if you select GET. Bubble doesn’t allow to send a body with a get request.