Reputation: 21
When I look up products I can get the product_id
that has upfront_fare_enabled
as true.
I then get the fare_id
.
However when I use that fare_id
to book a ride, I always get the error below;
{"meta":{},"errors":[{"status":422,"code":"upfront_fare_required","title":"A valid fare_id is required to request a trip with this product."}]}
Also, the product_id
that clearly says upfront_fare_enabled
is true.
If I lookup that product id it just says
"{"fare":{"breakdown":[{"type":"base_fare","name":"Base Fare","value":10.4}],"value":10.4"}"}"
Nothing about upfront_fare_enabled
.
I've cross-checked; the product_id
is correct.
What am I doing wrong and how can I fix it?
Upvotes: 1
Views: 399
Reputation: 13498
This is covered in the API docs https://developer.uber.com/docs/riders/ride-requests/tutorials/api/curl
The Uber API lets you Request an Uber Product for riders. Given you know a rider’s location, where they want to go, and which Uber product they want, you can request a ride for them with a few simple API endpoints.
In the products endpoint GET /products, products have the upfront_fare_enabled field set to true.
Use the request estimate endpoint POST /requests/estimate with a product_id to get a fare_id. The fare_id is used to set an upfront fare and arrival time for a trip. The fare_id expires after two minutes. If the fare_id expires or isn’t valid, a 422 error is returned.
Request a ride using the request endpoint POST /requests with the fare_id returned in the previous step.
See the API docs for the two APIs here
https://developer.uber.com/docs/riders/references/api/v1.2/requests-post#post-parameters
Upvotes: 1