Skip to main content
 首页 » 编程设计

python之Uber python API 在乘车请求时返回状态 409

2025年05月04日2352php

我正在按照 GitHub 项目页面上的说明进行操作
这一切都在沙盒模式

中运行

我先打电话

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 
) 

然后返回类似

的东西
{ 
"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 
} 

然后我使用上面获得的相同 product_id 和 fare_id(使用具有相同凭据的客户端对象)运行它

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 
  ) 

我得到的只是状态为 409 的 ClientError 异常。
知道出了什么问题吗?

请您参考如下方法:

409 错误很可能是由于您已经在该用户的沙盒中进行了一次旅行。您可以使用 client.get_current_ride_details() 检查并使用 client.cancel_current_ride() 取消正在进行的行程。