mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #305] Error with Recommendations #174
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#174
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @stant1er on GitHub (Jun 28, 2018).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/305
When using the recommendations request like this:
recommendations = spotify.recommendations(seed_tracks = track['id'])
I end up with this error:
Traceback (most recent call last):
File "AppData\Local\Programs\Python\Python36-32\lib\site-packages\spotipy\client.py", line 119, in _internal_call
r.raise_for_status()
File "AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\models.py", line 939, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.spotify.com/v1/recommendations?limit=20&seed_tracks=1%2Cp%2C8%2C0%2CL%2Cd%2Cx%2CR%2CV%2C7%2C4%2CU%2CK%2Cv%2CL%2C8%2Cg%2Cn%2CD%2C7%2Ck%2Cy
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "spotifytest.py", line 13, in
recommendations = spotify.recommendations(seed_tracks = track['id'])
File "AppData\Local\Programs\Python\Python36-32\lib\site-packages\spotipy\client.py", line 804, in recommendations
return self._get('recommendations', **params)
File "AppData\Local\Programs\Python\Python36-32\lib\site-packages\spotipy\client.py", line 146, in _get
return self._internal_call('GET', url, payload, kwargs)
File "AppData\Local\Programs\Python\Python36-32\lib\site-packages\spotipy\client.py", line 124, in _internal_call
headers=r.headers)
spotipy.client.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/recommendations?limit=20&seed_tracks=1%2Cp%2C8%2C0%2CL%2Cd%2Cx%2CR%2CV%2C7%2C4%2CU%2CK%2Cv%2CL%2C8%2Cg%2Cn%2CD%2C7%2Ck%2Cy:
invalid request
Does anyone know why I'm getting this error?
@brobotic commented on GitHub (Jul 4, 2018):
Sounds like track['id'] is just a string variable and not a list that contains URI strings. Even if it is just one track/artist/genre, it should be in a list.
You will want to make sure your seed track(s) are in a list, like so:
track = ['spotify:track:42GP0xKtkolBnmqQRvSllO']
And make sure that track is not just a string in a variable that contains the URI:
track = 'spotify:track:42GP0xKtkolBnmqQRvSllO'
I get the same error you do when using just a string in a variable for the seed track. Works fine when it's in a list.
@stephanebruckert commented on GitHub (Jan 12, 2020):
Hi @Stantl3r and thanks @brobotic, yes the doc says that
seed_tracksshould be a list.