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

时间:2017-03-10 19:12:48

标签: python uber-api

我正按照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
  )

我得到的只是ClientError例外,状态为409 知道什么是错的吗?

2 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:2)

发现了这个问题。我没有正确打印错误详细信息。结果我只看到了错误代码,而不是细节。

要查看我添加的完整错误详情:

    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))

然后我得到了这个非常有用的错误:
409 missing_payment_method骑手必须至少有一种付款方式才能申请汽车。骑车人必须添加付款方式

相关问题