Search code examples
apirestweb-servicesamadeus

Error sending dateTimeRange flight filters on request


I am sending a POST request with dateTimeRange filters to get flight offers on a particular time range.

When I use the departureDateTimeRange OR arrivalDateTimeRange, the response is working fine and returning the flights filtered by the departure/arrival time ranges that I have defined

{
"currencyCode": "EUR",
"originDestinations": [
    {
        "id": "1",
        "originLocationCode": "OPO",
        "destinationLocationCode": "FNC",
        "arrivalDateTimeRange": {
            "date": "2020-07-23",
            "time": "21:00:00",
            "timeWindow": "2H",
            "dateWindow": "P1D"
        }
    },
    {
        "id": "2",
        "originLocationCode": "FNC",
        "destinationLocationCode": "OPO",
        "departureDateTimeRange": {
            "date": "2020-07-24",
            "time": "08:00:00",
            "timeWindow": "1H",
            "dateWindow": "P1D"
        }
    }
],
"travelers": [
    {
        "id": "1",
        "travelerType": "ADULT"
    }
],
"sources": [
    "GDS"
],
"searchCriteria": {
    "flightFilters": {
        "cabinRestrictions": [
            {
                "cabin": "ECONOMY",
                "coverage": "ALL_SEGMENTS",
                "originDestinationIds": [
                    "1",
                    "2"
                ]
            }
        ],
        "connectionRestriction": {
            "maxNumberOfConnections": 2
        }
    },
    "pricingOptions": {
        "includedCheckedBagsOnly": true
    }
}

}

But I'd like to filter the Departure time AND the Arrival time altogether... let's pretend I want to departure between 07:00h and 09:00h, and arrive between 08:00h and 09:00h, in a 1 hour flight.

{
"currencyCode": "EUR",
"originDestinations": [
    {
        "id": "1",
        "originLocationCode": "OPO",
        "destinationLocationCode": "LIS",
        "departureDateTimeRange": {
            "date": "2020-07-23",
            "time": "08:00:00",
            "timeWindow": "1H",
            "dateWindow": "P1D"
        },
        "arrivalDateTimeRange": {
            "date": "2020-07-23",
            "time": "09:00:00",
            "timeWindow": "1H",
            "dateWindow": "P1D"
        }
    },
    {
        "id": "2",
        "originLocationCode": "LIS",
        "destinationLocationCode": "OPO",
        "departureDateTimeRange": {
            "date": "2020-07-24",
            "time": "08:00:00",
            "timeWindow": "1H",
            "dateWindow": "P1D"
        },
        "arrivalDateTimeRange": {
            "date": "2020-07-24",
            "time": "09:00:00",
            "timeWindow": "1H",
            "dateWindow": "P1D"
        }
    }
],
"travelers": [
    {
        "id": "1",
        "travelerType": "ADULT"
    }
],
"sources": [
    "GDS"
],
"searchCriteria": {
    "flightFilters": {
        "cabinRestrictions": [
            {
                "cabin": "ECONOMY",
                "coverage": "ALL_SEGMENTS",
                "originDestinationIds": [
                    "1",
                    "2"
                ]
            }
        ],
        "connectionRestriction": {
            "maxNumberOfConnections": 2
        }
    },
    "pricingOptions": {
        "includedCheckedBagsOnly": true
    }
}

The response is an error:

"errors": [
{
  "code": 2668,
  "title": "PARAMETER COMBINATION INVALID/RESTRICTED",
  "detail": "departureDateTimeRange and arrivalDateTimeRange are not compatible",
  "source": {
    "pointer": "/originDestinations[0]"
  },
  "status": 400
},
{
  "code": 2668,
  "title": "PARAMETER COMBINATION INVALID/RESTRICTED",
  "detail": "departureDateTimeRange and arrivalDateTimeRange are not compatible",
  "source": {
    "pointer": "/originDestinations[1]"
  },
  "status": 400
}

]

Does this actually mean that I cannot, at all, combine departureTimeRange and arrivalDateTimeRange on the same request, or am I doing something wrong/missing something here on the request details?

Thank you!


Solution

  • You are not doing anything wrong. The Flight Offers Search API doesn't allow you to search by using both the departureTimeRange AND the arrivalDateTimeRange, you can use one or the other feature. The logic behind is to return all the flights available to either leave at a specific time or to arrive at the destination at a specific time.

    If you want to check the departureTime AND the arrivalTime you need to use departureTimeRange and filter in the response the arrivalTime.

    If you want to have the list of flights that either leave at a specific time OR arrive at a specific time then you need to call the API twice using once departureTimeRange and the other one arrivalDateTimeRange.