【问题标题】:Booking Ride with Uber API使用 Uber API 预订行程
【发布时间】:2019-06-13 13:06:07
【问题描述】:

当我查找产品时,我可以得到 product_id,其中 upfront_fare_enabled 为 true。

然后我得到fare_id

但是,当我使用 fare_id 预订行程时,我总是收到以下错误;

{"meta":{},"errors":[{"status":422,"code":"upfront_fare_required","title":"A 使用此产品申请旅行需要有效的 fare_id。"}]}

另外,明确表示upfront_fare_enabledproduct_id 是真的。

如果我查找它只是说的那个产品 id

"{"fare":{"breakdown":[{"type":"base_fare","name":"Base Fare","value":10.4}],"value":10.4"}"}"

upfront_fare_enabled 无关。

我已经交叉检查了; product_id 是正确的。

我做错了什么,我该如何解决?

【问题讨论】:

    标签: uber-api


    【解决方案1】:

    API 文档 https://developer.uber.com/docs/riders/ride-requests/tutorials/api/curl 对此进行了介绍

    Uber API 可让您为乘客请求 Uber 产品。给你 了解乘客的位置、他们想去的地方以及优步的产品 他们想要,您可以通过一些简单的 API 为他们叫车 端点。

    在产品端点 GET /products 中,产品具有 upfront_fare_enabled 字段设置为 true。

    使用请求估算 端点 POST /requests/estimate 使用 product_id 获取 fare_id。 fare_id 用于设置预付费用和到达时间 旅行。 fare_id 将在两分钟后过期。如果 fare_id 过期或 无效,返回 422 错误。

    使用请求叫车 端点 POST /requests 使用之前返回的 fare_id 一步。

    在此处查看这两个 API 的 API 文档

    https://developer.uber.com/docs/riders/references/api/v1.2/requests-estimate-post#example-response-with-surge-pricing

    https://developer.uber.com/docs/riders/references/api/v1.2/requests-post#post-parameters

    【讨论】:

    • 仍然无法工作 :( 在尝试预订行程之前,我会查找产品。{"products":[{"upfront_fare_enabled":true,"capacity":4,"product_id" :"28fc0b4e-3f7f-431a-889e-84e9cb4192e1", Fare ID call 使用相同地址没有问题。{"fare":{"breakdown":[{"type":"base_fare","name":"Base Fare ","value":10.59}],"value":10.59,"fare_id":"b2b8644ff572bcd80f1de440238a7ed4885f731a21e1424a8240a970d15760da", 但是预订行程。{"meta":{},"errors":[{"status":422," code":"upfront_fare_required","title":"使用此产品申请旅行需要有效的 fare_id。"}]}
    • 我建议您发布更多代码,从您提供的输出的 sn-ps 中很难猜测。
    猜你喜欢
    • 2018-04-16
    • 2019-06-15
    • 1970-01-01
    • 1970-01-01
    • 2019-06-03
    • 1970-01-01
    • 2018-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多