guilhermesad / rspotify

A ruby wrapper for the Spotify Web API
MIT License
717 stars 290 forks source link

Show search returns `nil` items #253

Open domchristie opened 2 years ago

domchristie commented 2 years ago

Hey, I'm trying to perform a basic Show search. I authenticate with my credentials and call the search method, however, the items array in the response is just a load of nils and so it throws an error when attempting to initialize a Show:

RSpotify.authenticate("…", "…")
# => true
RSpotify::Show.search("NPR")

Throws:

rspotify/show.rb:48:in `initialize': undefined method `[]' for nil:NilClass (NoMethodError)

Any pointers for a fix?

Many thanks!

ZackAttax commented 11 months ago

Seems like a market is necessary but it's not very clear.

From the API docs :

market string An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that is available in that market will be returned. If a valid user access token is specified in the request header, the country associated with the user account will take priority over this parameter. Note: If neither market or user country are provided, the content is considered unavailable for the client. Users can view the country that is associated with their account in the account settings.

Example: market=ES

Making an API request in the docs you get "href"=>"https://api.spotify.com/v1/search?query=foo&type=show&locale=en-US%2Cen%3Bq%3D0.9%2Cla%3Bq%3D0.8&offset=0&limit=20"

using the gem you get "href"=>"https://api.spotify.com/v1/search?query=foo&type=show&offset=0&limit=20"

I added a market and was able to get a response in the items key.