rspotify icon indicating copy to clipboard operation
rspotify copied to clipboard

Show search returns `nil` items

Open domchristie opened this issue 2 years ago • 1 comments

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!

domchristie avatar Jun 04 '22 00:06 domchristie

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.

ZackAttax avatar Nov 29 '23 16:11 ZackAttax