API call error HTTP 400

Hello, I’m trying to set up Uber Direct API using Bubble’s API connector. This is the body for the API call:

{
  "pickup_address": "<pickup_address>",
  "dropoff_address": "<dropoff_address>",
  "pickup_latitude": <pickup_latitude>,
  "pickup_longitude": <pickup_longitude>,
  "dropoff_latitude": <dropoff_latitude>,
  "dropoff_longitude": <dropoff_longitude>,
  "pickup_ready_dt": "<pickup_ready_dt>",
  "pickup_deadline_dt": "<pickup_deadline_dt>",
  "dropoff_ready_dt": "<dropoff_ready_dt>",
  "dropoff_deadline_dt": "<dropoff_deadline_dt>",
  "pickup_phone_number": "<pickup_phone_number>",
  "dropoff_phone_number": "<dropoff_phone_number>",
  "manifest_total_value": <manifest_total_value>,
  "external_store_id": "Test"
}

I tested using Postman to test my Uber Direct credentials and substituting the dynamic values for static values and got a successful response which tells me that the body is well structured

 {
  "pickup_address": "{\"street_address\":[\"100 Maiden Ln\"],\"city\":\"New York\",\"state\":\"NY\",\"zip_code\":\"10023\",\"country\":\"US\"}",
  "dropoff_address": "{\"street_address\":[\"30 Lincoln Center Plaza\"],\"city\":\"New York\",\"state\":\"NY\",\"zip_code\":\"10023\",\"country\":\"US\"}",
  "pickup_latitude": 40.7066581,
  "pickup_longitude": -74.0071868,
  "dropoff_latitude": 40.7725,
  "dropoff_longitude": -73.9835,
  "pickup_ready_dt": "2025-04-24T20:45:00.000Z",
  "pickup_deadline_dt": "2025-04-24T21:00:00.000Z",
  "dropoff_ready_dt": "2025-04-24T21:00:00.000Z",
  "dropoff_deadline_dt": "2025-04-24T22:30:00.000Z",
  "pickup_phone_number": "+15555555555",
  "dropoff_phone_number": "+15555555555",
  "manifest_total_value": 1000,
  "external_store_id": "Test"
}

The problem comes when I try to initialize the API call in Bubble I get the following error:

The service this service just returned an error (HTTP 400). Please consult their documentation to ensure your call is setup properly. Raw error:
{"error":"failed to parse incoming request json: invalid character 'c' looking for beginning of value"}

I suspect is a problem on how Bubble is interpreting the dynamic values I use. Please let me know any suggestions or advice.

Thank you.

Can you share what you have set in API connector to initialize? (Pretty sure I’ve answered you in another topics for the same case telling you how to do the formatting for pickup and dropdoff in the action… in API connector, you can just copy paste what you are sending in POSTMAN). Actually, you should remove double quotes in pickup_address and dropoff address

{
  "pickup_address": <pickup_address>,
  "dropoff_address": <dropoff_address>,
  "pickup_latitude": <pickup_latitude>,
  "pickup_longitude": <pickup_longitude>,
  "dropoff_latitude": <dropoff_latitude>,
  "dropoff_longitude": <dropoff_longitude>,
  "pickup_ready_dt": "<pickup_ready_dt>",
  "pickup_deadline_dt": "<pickup_deadline_dt>",
  "dropoff_ready_dt": "<dropoff_ready_dt>",
  "dropoff_deadline_dt": "<dropoff_deadline_dt>",
  "pickup_phone_number": "<pickup_phone_number>",
  "dropoff_phone_number": "<dropoff_phone_number>",
  "manifest_total_value": <manifest_total_value>,
  "external_store_id": "Test"
}

And set value as

"{\"street_address\":[\"100 Maiden Ln\"],\"city\":\"New York\",\"state\":\"NY\",\"zip_code\":\"10023\",\"country\":\"US\"}"
"{\"street_address\":[\"30 Lincoln Center Plaza\"],\"city\":\"New York\",\"state\":\"NY\",\"zip_code\":\"10023\",\"country\":\"US\"}"

Including the double quotes in the value

Hello Jici,
Yes you did tell me how to format the pickup and dropoff addresses using arbitrary text and was very helpful. This is how I have set up the API body:

This is how I set up the pickup/dropoff addresses as a string:

These are the dynamic values I set for the Uber Direct API call:

Let me know if you need any more info.

Thank you.

in API Connector, you need to add double quotes around your pickup and dropoff address VALUES (not in the JSON body) You didn’t do this. Check my previous reply…
In the ACTION, remove the double quotes and don’t escape anything. USE instead a correctly formatted json and after arbitrary-text, add :formatted as json-safe. Let’s Bubble do the encoding correctly.

{
    "street_address": ["Checkoup page's Current cart's seller's address:extract street"],
    "city": "Checkout current cart's seller's city",
    "state": "Checkout current cart's seller's state",
    "zip_code": "Checkout current cart's seller's zip",
    "country": "Checkout current cart's seller's country"
}

From your previous response and code I thought I had to remove double quotes in pickup_address and dropoff address in the API connector.

Is this what you suggested?

This is the Log I get when using the above process.

That should work, however, I should have set the json without any new line in it instead. But if this work, keep it as it is easier to read :wink: