Search code examples
sabre

BFM v4.2.0 How to add DepartureDateTime


how do you add the departure date time in the request for C#? here is part of the code

   refOrgDest = new BFMV430.OTA_AirLowFareSearchRQOriginDestinationInformation
                        {
                            OriginLocation = new BFMV430.OriginDestinationInformationTypeOriginLocation { LocationCode
= refItin.Origin },
                            DestinationLocation = new BFMV430.OriginDestinationInformationTypeDestinationLocation { LocationCode = refItin.Destination },
                            RPH = (i + 1).ToString(),
                            TPA_Extensions = new BFMV430.OTA_AirLowFareSearchRQOriginDestinationInformationTPA_Extensions
                            {
                                CabinPref = new BFMV430.CabinPrefType
                                {
                                    Cabin = (BFMV430.CabinType)Enum.Parse(typeof(BFMV430.CabinType), refResBookType, true),
                                    PreferLevel = BFMV430.PreferLevelType.Preferred,
                                    CabinSpecified = true,
                                }
                            },
                            ItemElementName = BFMV430.ItemChoiceType.DepartureDateTime,
                            Item = new BFMV430.TravelDateTimeType
                            {
                                DepartureWindow = "00002359",
                            },                            
                        };
                        refOrgDestList.Add(refOrgDest);

also I'm getting this mismatch error when running it

Value of ItemElementName mismatches the type of System.String; you need to set it to prjWService.BFMV430.ItemChoiceType.@DepartureDateTime.

any help would be great.

thanks in advance


Solution

  • Here is a piece of code that could help you, the interesting part is about the date format expected by Sabre for all transaction related to search flight/availability, it means (BMF, ADVShopping, AirLowFare and etc is gonna to use the same date format). (2019-04-14T00:00:00)

                __ItemOriginDestination = new AdvacedAirShopping.OTA_AirLowFareSearchRQOriginDestinationInformation
                {
                    RPH = "1",
                    ItemElementName = AdvacedAirShopping.ItemChoiceType.DepartureDateTime,
                    Item = _FlightSearch.DepartureDateTime, //"2019-04-14T00:00:00" Here is the format expected by Sabre
    
                    OriginLocation = new AdvacedAirShopping.OriginDestinationInformationTypeOriginLocation
                    {
                        LocationCode = _FlightSearch.Origin
                    },
                    DestinationLocation = new AdvacedAirShopping.OriginDestinationInformationTypeDestinationLocation
                    {
                        LocationCode = _FlightSearch.Destination
                    }
                };