php 在测试环境下创建订单时,我一直收到Amadeus发送的400错误信息

rggaifut  于 2023-08-02  发布在  PHP
关注(0)|答案(1)|浏览(138)

我正在尝试将JSON数据发送到Amadeus,但我一直收到The requested URL returned error: 400 Bad Request。昨天它工作正常,今天我用新数据进行测试,但不断收到错误信息。我试过Amadeus网站和 Postman ,没有一个工作,并得到相同的信息。在Postman上,我收到详细信息:无法销售段1,如下面的代码所示:-

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

字符串
我想我可能已经用完了Amadeus提供的测试环境的津贴,经过检查,我只使用了196/10000。所以这也不是问题所在。
我发送给Amadeus的数据是通过curl请求的,请找到下面的代码:-

{
   "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
               }
            ]
         }
      ]
   }
}


我的curl请求是:-

$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;


如果你遇到或面对这个问题或解决这个问题,请让我知道。

mefy6pfw

mefy6pfw1#

我也有同样的问题需要你的帮助。

相关问题