Search code examples
.netsdkamadeus

Amadeus .Net Sdk shows 401 error for shopping.flightOffers.get function though other function works


I am trying .Net SDK for amadeus self service API integration from https://github.com/amadeus4dev/amadeus-dotnet.

I have tested some endpoints successfully but failed to get result for low price flight search API.

From their documentation code below should work but it shows 401 error:

// Flight Low-fare Search
FlightOffer[] flightOffers = amadeus.shopping.flightOffers.get(Params
  .with("origin", "NYC")
  .and("destination", "MAD")
  .and("departureDate", "2021-05-01"));

Solution

  • Need to change versions of API from V1 to V2. Change the URL on the FlightOffers class to: /v2/shopping/flight-offers In addition the parameters name also changed: originLocationCode, destinationLocationCode.

    amadeus.resources.FlightOffer[] flightOffer = amadeus.shopping.flightOffers.get(Params
                .with("originLocationCode", "LHR")
                .and("destinationLocationCode", "LAX")
                .and("departureDate", "2021-12-24")
                .and("adults", "1"));