-2

I'm using the Uber API to create a ride request (with node-uber)

I first get the user authenticated (uber.authorization after getting a calback from uber.getAuthorizeUrl).

Then I call the estimate API and get a response (estimates.getPriceForRoute)

I then use the same start & end coordinates with the product ID returned in the estimate (requests.create).

I always get back: HTTP Response with error code: 409

Any suggestions?

UPDATE Here is the code for the estimate request (which works perfectly)

router.get('/estimate', function(request, response, next) {
  var query = url.parse(request.url, true).query;

  if (!query || !query.start_lat || !query.start_lng || !query.end_lat || !query.end_lng) {
     response.sendStatus(400);
  } else {
     uber.estimates.getPriceForRoute(query.start_lat, query.start_lng, query.end_lat, query.end_lng , 1, function(err, res){
  if (err) {
    console.error(err);
    response.sendStatus(500);
  } else {
    var productType = getProductType(query);
    var selectedProduct = _.find(res.prices, function(price){
      return price.display_name == productType;
    });
    response.json(selectedProduct);
  }
});

} });

Here is the response I get

{"localized_display_name":"uberX","high_estimate":7,"minimum":7,"duration":240,"estimate":"$7-7","distance":0.95,"display_name":"uberX","product_id":"a1111c8c-c720-46c3-8534-2fcdd730040d","low_estimate":7,"surge_multiplier":1,"currency_code":"USD"}

Now the part that has the problem:

router.get('/request', function(request, response, next) {
  var query = url.parse(request.url, true).query;

  if (!query || !query.start_lat || !query.start_lng || !query.end_lat || !query.end_lng || !query.productId) {
    response.sendStatus(400);
  } else {
    uber.requests.create({
      "product_id": query.productId,
      "start_latitude": query.start_lat,
      "start_longitude": query.start_lng,
      "end_latitude": query.end_lat,
      "end_longitude": query.end_lng
    }, function (err, res) {
      if (err) {
        console.error("error: " + err);
        response.sendStatus(400);
      } else {
        //console.log(res);
        response.json(res);
      }
    });
  }
});

the line console.error("error: " + err); returns this output:

error: HTTP Response with error code: 409

Ron Harlev
  • 16,227
  • 24
  • 89
  • 132

1 Answers1

0

Could you please share your source code? I assume you try to call /v1/requests/estimate endpoint. This endpoints can return a 409 - Conflict. This status indicates that there is a surge in place right now. Here is a description of the surge flow: enter image description here

The node-uber project does not actively support with handling a surge in the released version. However, there is a branch for v1.0.0 and someone started working on a direct support, as listed in this issue conversation.

Alexander Graebe
  • 797
  • 5
  • 10
  • I'm trying to call `requests.create`. I don't believe there is a constant surge. The estimate request shows no surge – Ron Harlev Sep 13 '16 at 18:43
  • Which product do you want to request? Please add some code to your question... Also, could you add a more detailed debug/error message? Thanks! – Alexander Graebe Sep 13 '16 at 19:54