[GH-ISSUE #1169] current_user_followed_artists() results in http status 400 #687

Closed
opened 2026-02-28 00:00:51 +03:00 by kerem · 2 comments
Owner

Originally created by @fivebanger on GitHub (Nov 26, 2024).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1169

Describe the bug
Call of current_user_followed_artists(limit=20, after=None) first time (i.e. after is not known yet) results in http status 400.

current_user_followed_artists(limit=20, after=None) results in message

Sending GET to https://api.spotify.com/v1/me/following with Params: {'type': 'artist', 'limit': 20, 'after': 0} Headers: {'Authorization': 'Bearer xxx', 'Content-Type': 'application/json'} and Body: None

whereas after evaluates to 0 and spotipy raises exception

File "/home/martin/.kodi/addons/plugin.audio.hotspot/libs/spotipy/spotipy/client.py", line 1439, in current_user_followed_artists
return self._get(
File "/home/martin/.kodi/addons/plugin.audio.hotspot/libs/spotipy/spotipy/client.py", line 327, in _get
return self._internal_call("GET", url, payload, kwargs)
File "/home/martin/.kodi/addons/plugin.audio.hotspot/libs/spotipy/spotipy/client.py", line 297, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/me/following?type=artist&limit=50&after=0:
Invalid base62 id, reason: None

Your code
Call current_user_followed_artists(limit=20, after=None)

Environment:

  • OS: Linux Mint / LibreELEC / Win10
  • spotipy version 2.24.0

Additional context
Most likely this behavior was changed by Spotify. According to current Spotify developer site, the first call of /v1/me/following has to be called without the after parameter:

curl --request GET \
  --url 'https://api.spotify.com/v1/me/following?type=artist' \
  --header 'Authorization: Bearer xxx...'

Quick fix inside function current_user_followed_artists():

Change

return self._get(
    "me/following", type="artist", limit=limit, after=after
)

to

if after:
    return self._get(
        "me/following", type="artist", limit=limit, after=after
    )
else:
    return self._get(
        "me/following", type="artist", limit=limit
    )

which results in message

Sending GET to https://api.spotify.com/v1/me/following with Params: {'type': 'artist', 'limit': 20} Headers: {'Authorization': 'Bearer xxx', 'Content-Type': 'application/json'} and Body: None

not sending the after parameter. A properly populated list of followed artists is returned.

Originally created by @fivebanger on GitHub (Nov 26, 2024). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1169 **Describe the bug** Call of `current_user_followed_artists(limit=20, after=None)` first time (i.e. `after` is not known yet) results in http status 400. `current_user_followed_artists(limit=20, after=None)` results in message ``` Sending GET to https://api.spotify.com/v1/me/following with Params: {'type': 'artist', 'limit': 20, 'after': 0} Headers: {'Authorization': 'Bearer xxx', 'Content-Type': 'application/json'} and Body: None ``` whereas `after` evaluates to `0` and spotipy raises exception ``` File "/home/martin/.kodi/addons/plugin.audio.hotspot/libs/spotipy/spotipy/client.py", line 1439, in current_user_followed_artists return self._get( File "/home/martin/.kodi/addons/plugin.audio.hotspot/libs/spotipy/spotipy/client.py", line 327, in _get return self._internal_call("GET", url, payload, kwargs) File "/home/martin/.kodi/addons/plugin.audio.hotspot/libs/spotipy/spotipy/client.py", line 297, in _internal_call raise SpotifyException( spotipy.exceptions.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/me/following?type=artist&limit=50&after=0: Invalid base62 id, reason: None ``` **Your code** Call `current_user_followed_artists(limit=20, after=None)` **Environment:** - OS: Linux Mint / LibreELEC / Win10 - spotipy version 2.24.0 **Additional context** Most likely this behavior was changed by Spotify. According to current Spotify developer site, the first call of `/v1/me/following` has to be called without the `after` parameter: ``` curl --request GET \ --url 'https://api.spotify.com/v1/me/following?type=artist' \ --header 'Authorization: Bearer xxx...' ``` Quick fix inside function `current_user_followed_artists()`: Change ``` return self._get( "me/following", type="artist", limit=limit, after=after ) ``` to ``` if after: return self._get( "me/following", type="artist", limit=limit, after=after ) else: return self._get( "me/following", type="artist", limit=limit ) ``` which results in message ``` Sending GET to https://api.spotify.com/v1/me/following with Params: {'type': 'artist', 'limit': 20} Headers: {'Authorization': 'Bearer xxx', 'Content-Type': 'application/json'} and Body: None ``` not sending the `after` parameter. A properly populated list of followed artists is returned.
kerem 2026-02-28 00:00:51 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@dieser-niko commented on GitHub (Nov 26, 2024):

The function works as expected. However, it expects a string or None, not an integer, which you seem to have passed to the function.

<!-- gh-comment-id:2499887721 --> @dieser-niko commented on GitHub (Nov 26, 2024): The function works as expected. However, it expects a string or None, not an integer, which you seem to have passed to the function.
Author
Owner

@fivebanger commented on GitHub (Nov 26, 2024):

Sorry for disruption, you are right. Issue was on my side calling current_user_followed_artists() with artists=0 instead of artists=None.

<!-- gh-comment-id:2500021291 --> @fivebanger commented on GitHub (Nov 26, 2024): Sorry for disruption, you are right. Issue was on my side calling current_user_followed_artists() with artists=0 instead of artists=None.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#687
No description provided.