-1

I am trying to send the json data to Amadeus and I keep on getting The requested URL returned error: 400 Bad Request. It was working properly yesterday, and today I was doing the testing with new data but keeps on getting the error message. I tried on Amadeus website and Postman, none of them work and getting the same message. On Postman, I get the details message saying: could not sell the segment 1 as in the code below:-

{
   "errors": [
      {
         "status": 400,
         "code": 34651,
         "title": "SEGMENT SELL FAILURE",
         "detail": "Could not sell segment 1",
         "source": {
            "pointer": "/data/flightOffers[0]/itineraries[0]/segments[0]"
         }
      }
   ]
}

I thought I may have run out of the allowance Amadeus provide on test environment and upon checking I have only used 196/10000. So, even this can't be the problem.

The data that I am sending to Amadeus is through curl request please find the code below:-

{
   "data": {
      "type": "flight-order",
      "flightOffers": [
         {
            "type": "flight-offer",
            "id": "4",
            "source": "GDS",
            "instantTicketingRequired": false,
            "nonHomogeneous": false,
            "paymentCardRequired": false,
            "lastTicketingDate": "2023-07-31",
            "itineraries": [
               {
                  "segments": [
                     {
                        "departure": {
                           "iataCode": "MEL",
                           "terminal": "2",
                           "at": "2023-11-01T21:40:00"
                        },
                        "arrival": {
                           "iataCode": "AUH",
                           "terminal": "3",
                           "at": "2023-11-02T05:05:00"
                        },
                        "carrierCode": "EY",
                        "number": "461",
                        "aircraft": {
                           "code": "77W"
                        },
                        "operating": {
                           "carrierCode": "EY"
                        },
                        "duration": "PT14H25M",
                        "id": "5",
                        "numberOfStops": 0,
                        "co2Emissions": [
                           {
                              "weight": 630,
                              "weightUnit": "KG",
                              "cabin": "ECONOMY"
                           }
                        ]
                     },
                     {
                        "departure": {
                           "iataCode": "AUH",
                           "terminal": "3",
                           "at": "2023-11-02T08:20:00"
                        },
                        "arrival": {
                           "iataCode": "LHR",
                           "terminal": "4",
                           "at": "2023-11-02T12:00:00"
                        },
                        "carrierCode": "EY",
                        "number": "19",
                        "aircraft": {
                           "code": "388"
                        },
                        "operating": {
                           "carrierCode": "EY"
                        },
                        "duration": "PT7H40M",
                        "id": "6",
                        "numberOfStops": 0,
                        "co2Emissions": [
                           {
                              "weight": 324,
                              "weightUnit": "KG",
                              "cabin": "ECONOMY"
                           }
                        ]
                     }
                  ]
               },
               {
                  "segments": [
                     {
                        "departure": {
                           "iataCode": "LHR",
                           "terminal": "4",
                           "at": "2023-11-30T21:05:00"
                        },
                        "arrival": {
                           "iataCode": "AUH",
                           "terminal": "3",
                           "at": "2023-12-01T07:50:00"
                        },
                        "carrierCode": "EY",
                        "number": "18",
                        "aircraft": {
                           "code": "388"
                        },
                        "operating": {
                           "carrierCode": "EY"
                        },
                        "duration": "PT6H45M",
                        "id": "63",
                        "numberOfStops": 0,
                        "co2Emissions": [
                           {
                              "weight": 324,
                              "weightUnit": "KG",
                              "cabin": "ECONOMY"
                           }
                        ]
                     },
                     {
                        "departure": {
                           "iataCode": "AUH",
                           "terminal": "3",
                           "at": "2023-12-01T09:30:00"
                        },
                        "arrival": {
                           "iataCode": "MEL",
                           "terminal": "2",
                           "at": "2023-12-02T06:00:00"
                        },
                        "carrierCode": "EY",
                        "number": "462",
                        "aircraft": {
                           "code": "77W"
                        },
                        "operating": {
                           "carrierCode": "EY"
                        },
                        "duration": "PT13H30M",
                        "id": "64",
                        "numberOfStops": 0,
                        "co2Emissions": [
                           {
                              "weight": 630,
                              "weightUnit": "KG",
                              "cabin": "ECONOMY"
                           }
                        ]
                     }
                  ]
               }
            ],
            "price": {
               "currency": "AUD",
               "total": "1653.58",
               "base": "1218.00",
               "fees": [
                  {
                     "amount": "0.00",
                     "type": "SUPPLIER"
                  },
                  {
                     "amount": "0.00",
                     "type": "TICKETING"
                  },
                  {
                     "amount": "0.00",
                     "type": "FORM_OF_PAYMENT"
                  }
               ],
               "grandTotal": "1653.58",
               "billingCurrency": "AUD"
            },
            "pricingOptions": {
               "fareType": [
                  "PUBLISHED"
               ],
               "includedCheckedBagsOnly": true
            },
            "validatingAirlineCodes": [
               "EY"
            ],
            "travelerPricings": [
               {
                  "travelerId": "1",
                  "fareOption": "STANDARD",
                  "travelerType": "ADULT",
                  "price": {
                     "currency": "AUD",
                     "total": "1653.58",
                     "base": "1218.00",
                     "taxes": [
                        {
                           "amount": "11.42",
                           "code": "WG"
                        },
                        {
                           "amount": "28.00",
                           "code": "F6"
                        },
                        {
                           "amount": "50.26",
                           "code": "WY"
                        },
                        {
                           "amount": "60.00",
                           "code": "AU"
                        },
                        {
                           "amount": "4.00",
                           "code": "ZR"
                        },
                        {
                           "amount": "174.70",
                           "code": "GB"
                        },
                        {
                           "amount": "107.20",
                           "code": "UB"
                        }
                     ],
                     "refundableTaxes": "435.58"
                  },
                  "fareDetailsBySegment": [
                     {
                        "segmentId": "5",
                        "cabin": "ECONOMY",
                        "fareBasis": "ENX03V5T",
                        "brandedFare": "YV",
                        "class": "E",
                        "includedCheckedBags": {
                           "weight": 30,
                           "weightUnit": "KG"
                        }
                     },
                     {
                        "segmentId": "6",
                        "cabin": "ECONOMY",
                        "fareBasis": "ENX03V5T",
                        "brandedFare": "YV",
                        "class": "E",
                        "includedCheckedBags": {
                           "weight": 30,
                           "weightUnit": "KG"
                        }
                     },
                     {
                        "segmentId": "63",
                        "cabin": "ECONOMY",
                        "fareBasis": "VLW13V5R",
                        "brandedFare": "YV",
                        "class": "V",
                        "includedCheckedBags": {
                           "weight": 30,
                           "weightUnit": "KG"
                        }
                     },
                     {
                        "segmentId": "64",
                        "cabin": "ECONOMY",
                        "fareBasis": "VLW13V5R",
                        "brandedFare": "YV",
                        "class": "V",
                        "includedCheckedBags": {
                           "weight": 30,
                           "weightUnit": "KG"
                        }
                     }
                  ]
               }
            ]
         }
      ],
      "travelers": [
         {
            "id": 1,
            "dateOfBirth": "1981-10-18",
            "gender": "MALE",
            "name": {
               "firstName": "Kunal Gunvant",
               "lastName": "Parekh"
            },
            "contact": {
               "emailAddress": "kunal.libra@gmail.com",
               "phones": [
                  {
                     "deviceType": "MOBILE",
                     "countryCallingCode": "213",
                     "number": "0439378608"
                  }
               ]
            },
            "documents": [
               {
                  "number": "90wjwi",
                  "issuanceDate": "2020-08-11",
                  "expiryDate": "2030-08-11",
                  "issuanceCountry": "AU",
                  "issuanceLocation": "Melbourne",
                  "nationality": "AU",
                  "birthPlace": "Mumbai",
                  "documentType": "PASSPORT",
                  "holder": true
               }
            ]
         }
      ]
   }
}

And my curl request is: -

$xtoken = $this->amadeus_auth_test();
$auth = "Authorization: Bearer " .  $xtoken;

$url = "https://test.api.amadeus.com/v1/booking/flight-orders";
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt(
    $curl,
    CURLOPT_HTTPHEADER,
    array(
        $auth,
        "Content-Type:application/json",
    )
);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_FAILONERROR, true);

$token = curl_exec($curl);

$arr = json_decode($token, true);

$err = curl_error($curl);

curl_close($curl);

dump($err);

return  $arr;

If you have come across or faced this problem or solved this problem please let me know.

matiaslauriti
  • 7,065
  • 4
  • 31
  • 43
Kunal Parekh
  • 380
  • 6
  • 24
  • The message _"Could not sell segment 1"_ is likely not related to the number of requests you've already done (which is way below limit), but only that the segment could not be sold. Resolve the [JSON Path](https://stackoverflow.com/questions/45765454/parsing-json-using-php-jsonpath) (they call it _pointer_, but [JSON Pointer](https://www.rfc-editor.org/rfc/rfc6901) is similar but different) on the JSON you have in the request to learn about the segment that caused it. E.g. imagine all seats on that segment are already booked. – hakre Jul 22 '23 at 16:02
  • Why are you using `curl_xxx` instead of the [`Http` facade](https://laravel.com/docs/10.x/http-client)? And you are using `array` instead of `[]`, you need update your code to newer standards so it is more readable – matiaslauriti Jul 22 '23 at 16:23
  • Hey, the array code I provided is copy paste as I had downloaded the Amadeus Postman code where they have provided with all the APIs. So I had copy paste and it is in the same format which they provided in their samples. – Kunal Parekh Jul 22 '23 at 17:38

1 Answers1

0

Moi aussi j'ai le même problème, on a besoin d'aide svp.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 28 '23 at 16:10