Passing a list of database ID's through API connector

Hi Guys, Im trying to send a list of unique records of my database through the API connector but any example i provide fails to initialize

example - “work_orders”: [“1771223277996x175887814820627760”, “1771223277996x313609477164249000”]

appreciate any help.

I think the body of your connector should be like this

{
“contributor”: “<contributor>”,
“check_in”: “<check_in>”,
“work_orders”: <list_of_work_orders>
}

Work orders value shouldn’t be in quotes, remember they are perceived as strings not as numbers

When u’re parsing it, ie testing it out, it should be like this for example

{
“contributor”: “1234567890”,
“check_in”: “1670000000000”,
“work_orders”: [
“1771223277996x175887814820627760”,
“1771223277996x313609477164249000”
]
}

Try it, this might solve the problem

1 Like

There’s a syntax error. Look at “work_orders”. In your Body you have “work_orders”: ““. But inside your you’re passing an array of strings. Remove the quotes around so that you can pass the array of strings.

There might be more errors, but the screenshot is blocked by the popup. Regardless, when you get a JSON error like this the cause is most likely a syntax issue.

1 Like

The error Unexpected number in JSON at position… usually means the JSON body you’re sending is not valid JSON – Bubble is treating at least one value as a raw number / text instead of a properly formatted JSON array or object.

For a list you normally need something like:

json

{
"contributor": 1758176,
"check_in": 1761493,
"work_orders": [177123, 177124, 177125]
}

or, if the API expects objects:

json

{
"contributor": 1758176,
"check_in": 1761493,
"work_orders": [
{ "id": 177123 },
{ "id": 177124 }
]
}

In the API Connector, instead of putting a Bubble expression directly in the raw JSON, define a body parameter like work_orders and send it as JSON with something like Do a search for Work Orders:unique elements:formatted as text where:

  • Separator is ,

  • Each item’s format is {"id": [This Work Order's unique id]}

    Then wrap that whole thing in [ and ] so you end up with a valid JSON array.

Right now the initializer is probably seeing something like 177123 5525493... concatenated or without brackets/quotes, so it throws the parse error. If you can share the exact body you’re sending for "work_orders", we can tweak the expression so it becomes valid JSON.