Search code examples
pythonuber-api

Uber python API returns status 409 on ride request


I'm following the instructions on the project page on GitHub
This is all running in sandbox mode

First I'm calling

estimate = client.estimate_ride(
  product_id=product_id,
  start_latitude=start_lat,
  start_longitude=start_long,
  end_latitude=end_lat,
  end_longitude=end_long,
  seat_count=seat_count
)

and getting back something like

{
"pickup_estimate": 2,
"trip": {
    "distance_estimate": 2.18,
    "distance_unit": "mile",
    "duration_estimate": 240
},
"fare": {
    "fare_id": "14f81e7421f0ae124c2e5a97d0b9cf975cbb84fdd2bf6fc8b7bb2f49fc6c6f8a",
    "value": 8.06,
    "display": "$8.06",
    "currency_code": "USD",
    "expires_at": 1489104865
}

}

Then I'm using the same product_id and the fare_id I got above (with a client object with the same credentials) running this

response = client.request_ride(
      product_id=product_id,
      start_latitude=start_lat,
      start_longitude=start_long,
      end_latitude=end_lat,
      end_longitude=end_long,
      seat_count=seat_count,
      fare_id=fare_id
  )

All I get is a ClientError exception with status 409.
Any idea what's wrong?


Solution

  • Found the issue. I wasn't printing the error details correctly. As a result I saw just the error code and not the details.

    To see the full error details I added:

        try:
          response = client.request_ride(
            product_id=product_id,
            start_latitude=start_lat,
            start_longitude=start_long,
            end_latitude=end_lat,
            end_longitude=end_long,
            seat_count=seat_count,
            fare_id=fare_id
         )
       except ClientError as error:
         self.response.out.write("error: {0}, {1}".format(error.errors, error.message))
    

    Then I got this error that is very informative:
    409 missing_payment_method The rider must have at least one payment method on file to request a car. The rider must add a payment method