Hello,
I’ve set up an integration between Bubble and the Geopify Route Planner API using the API Connector. It’s a POST request with dynamic parameters. The request body looks like this:
{
"mode": "drive",
"agents": [
{
"id": "Routey",
"start_location": [
<homebase_longitude>,
<homebase_latitude>
],
"end_location": [
<finishbase_longitude>,
<finishbase_latitude>
],
"time_windows": [
[
<starttime_user>,
86400
]
]
}
],
"shipments": [
<shipments_array>
]
}
The workflow step that builds the dynamic parameter array is structured like this:
(body) homebase_longitude:-79.4270925
(body) homebase_latitude:43.844774
(body) finishbase_longitude:-79.4270925
(body) finishbase_latitude:43.844774
(body) starttime_user:0
(body) shipments_array:{"id": "1740548256333x704081110796861400", "pickup": {
"location": [
-79.4270925,
43.844774
],
"duration": 300
}, "delivery": {
"location": [
-79.3803654,
43.6415938
],
"duration": 900
}}
However, I’m getting the following error:
Workflow error - The service Geopify API - Route Planner API call just returned an error (HTTP 400). Please consult their documentation to ensure your call is set up properly. Raw error: {“statusCode”:400,“error”:“Bad Request”,“message”:“Unexpected token \ in JSON at position 506”}
What I’ve Checked:
The JSON output passes validation in JSONLint, meaning there are no visible syntax errors.
The reported error references position 506, but some of my test payloads contain fewer than 400 characters (excluding commas), so the reference seems inconsistent.
Data Sources:
All data used in the request is retrieved from a temporary database table created specifically for assembling this JSON array.
The coordinates are fetched directly from the database without modifications.
The <shipments_array> is built using three pre-formatted text blocks, combined via Arbitrary text to ensure the correct structure.
The final array is assembled into a field using JSON_array with “join with ‘,’” before sending the request.
Here is an actual JSON request output displayed on-screen before sending:
{
"mode": "drive",
"agents": [
{
"id": "Routey",
"start_location": [
-79.3803887,
43.6510327
],
"end_location": [
-79.3803887,
43.6510327
],
"time_windows": [
[
0,
86400
]
]
}
],
"shipments": [
{"id": "1740544027934x507496224237551600", "pickup": {
"location": [
-79.3803887,
43.6510327
],
"duration": 300
}, "delivery": {
"location": [
-79.6085507,
43.5714273
],
"duration": 900
}},{"id": "1740544048140x629414809095372800", "pickup": {
"location": [
-79.6085507,
43.5714273
],
"duration": 300
}, "delivery": {
"location": [
-79.3847251,
43.6525022
],
"duration": 900
}},{"id": "1740544060674x298290248075444200", "pickup": {
"location": [
-79.3803887,
43.6510327
],
"duration": 300
}, "delivery": {
"location": [
-79.3708368,
43.6434596
],
"duration": 900
}}
]
}
Potential Issue:
I suspect Bubble might be inserting hidden characters into the request, even though they do not appear when inspecting the JSON output step-by-step or displaying it in a text field on the page.
Questions:
- Does Bubble insert any hidden characters that are not visible in step-by-step inspection or text field outputs?
- Are there known issues when assembling JSON arrays using Arbitrary text and join with “,” that could be causing formatting errors?
- Is there a way to log the exact raw request Bubble sends to Geopify for further debugging?
Any insights would be greatly appreciated!
Thanks!