2017-03-10 56 views
1

我下面就GitHub
該項目頁面上的說明狀況409是所有沙盒模式下運行尤伯杯的Python API返回的乘坐要求

首先我打電話

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

發現問題。我沒有正確打印錯誤的詳細信息。結果我只看到了錯誤代碼,而沒有看到細節。

要查看完整的錯誤細節我補充說:

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的騎手必須在文件中至少有一種付款方式,要求汽車。騎手必須添加付款方式

3

409錯誤很可能是由於您已經在此用戶的沙盒中進行了旅程。您可以使用client.get_current_ride_details()進行檢查,並使用client.cancel_current_ride()取消正在進行的旅程。

+0

client.get_current_ride_details()返回'ClientError:404'。 文檔說「如果沒有正在進行的旅程,端點將導致404找不到錯誤」 –

相關問題