Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pass arrays as parameters to hotels.byCity.get endpoint: it results in a 400 response #220

Open
gianpieropuleo opened this issue Sep 6, 2024 · 0 comments

Comments

@gianpieropuleo
Copy link

gianpieropuleo commented Sep 6, 2024

Description

The amadeus.referenceData.locations.hotels.byCity.get endpoint seems to not support passing arrays as parameters

Steps to Reproduce

const getHotelsByCity = async ({
  cityCode,
  radius = 5,
  radiusUnit = "KM",
  chainCodes = [],
  amenities = [],
  ratings = [],
  hotelSource = "ALL",
}) => {
 const result = await amadeus.referenceData.locations.hotels.byCity
    .get({
      cityCode,
      radius,
      radiusUnit,
      chainCodes,
      amenities,
      ratings,
      hotelSource,
    })
    .catch((error) => {
      console.error(error);
    });

  return result;
};

Expected Behavior:

I would have expected to be able to pass arrays, give we're working with Node. Plus the documentation says those parameters (chainCodes, amenities and ratings) are arrays of strings.

Actual Behavior:

When passing an array to any of those parameters, the response is 400, Invalid Format. This seems to be caused by how array get represented in the GET request:

'v1/reference-data/locations/hotels/by-city?cityCode=MIL&radius=5&radiusUnit=KM&hotelSource=ALL&amenities%5B0%5D=FITNESS_CENTER&ratings%5B0%5D=4&ratings%5B1%5D=5'

In order for it to work, I need to convert them to comma separated values. The documentation for ratings gave a hint on that:

chainCodes.join(",");

Maybe this is expected behavior, but in that case perhaps it should be documented and/or added in the code example.

Stable Behavior?

100% of the times.

Versions

Running Node version 20.17.0 on MacOS Sonoma 14.6.1

Checklist

Please make sure you checked the following:

  • Are you running any of the current Node LTS versions? Yes
  • Did you download the latest version of this library? Yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant