[GH-ISSUE #1170] urllib3.exceptions.ResponseError: too many 502 error responses when using "playlist-modify-private" scope OAuth #690

Closed
opened 2026-02-28 00:00:53 +03:00 by kerem · 1 comment
Owner

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

Describe the bug

Encountering an error when trying to use the private playlist API to create a new playlist. Full log available in attached text file.

traceback.txt

I'm able to use the Client Credentials functionality just fine so I know it's not an issue with my API info.

Your code

This is the function:


# Globals
DEFAULT_SPOTIFY_API_SCOPE = "playlist-modify-private"

def create_playlist_from_tracks(spotify_tracks: list, playlist_name: str, playlist_description: str, spotify_api_obj) -> str:

    sp_obj = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=spotify_api_obj["client_id"], client_secret=spotify_api_obj["client_secret"], redirect_uri=spotify_api_obj["redirect_uri"], scope=DEFAULT_SPOTIFY_API_SCOPE))

    user_id = sp_obj.current_user()["id"]
    playlist_id = sp_obj.user_playlist_create(
        user_id, playlist_name, public=False, description=playlist_description)["id"]

    track_ids = [track["track_id"] for track in spotify_tracks]
    sp_obj.playlist_add_items(playlist_id, track_ids)

    return playlist_id

This function takes in a list of track IDs and creates a playlist for them. I have a separate function that uses the Search endpoint to find track IDs given a song name and artist name, that part works fine, I just get an error when I try to run this function to create a new playlist with those track IDs.

Output

Full traceback is available here

traceback.txt

Environment:

  • OS: [e.g. Windows, Mac]
  • Python version [e.g. 3.7.0]
  • spotipy version [e.g. 2.12.0]
  • your IDE (if using any) [e.g. PyCharm, Jupyter Notebook IDE, Google Colab]
OS: Ubuntu 24.04.1 LTS
Kernel: 6.8.0-48-generic

Packages and versions installed in virtual env:

certifi==2024.8.30
charset-normalizer==3.4.0
idna==3.10
redis==5.2.0
requests==2.32.3
spotipy==2.24.0
urllib3==2.2.3

Python version

Python 3.12.3

Additional context
Add any other context about the problem here.

Originally created by @raleighlittles on GitHub (Nov 26, 2024). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1170 **Describe the bug** Encountering an error when trying to use the private playlist API to create a new playlist. Full log available in attached text file. [traceback.txt](https://github.com/user-attachments/files/17924553/traceback.txt) I'm able to use the Client Credentials functionality just fine so I know it's not an issue with my API info. **Your code** This is the function: ```python # Globals DEFAULT_SPOTIFY_API_SCOPE = "playlist-modify-private" def create_playlist_from_tracks(spotify_tracks: list, playlist_name: str, playlist_description: str, spotify_api_obj) -> str: sp_obj = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=spotify_api_obj["client_id"], client_secret=spotify_api_obj["client_secret"], redirect_uri=spotify_api_obj["redirect_uri"], scope=DEFAULT_SPOTIFY_API_SCOPE)) user_id = sp_obj.current_user()["id"] playlist_id = sp_obj.user_playlist_create( user_id, playlist_name, public=False, description=playlist_description)["id"] track_ids = [track["track_id"] for track in spotify_tracks] sp_obj.playlist_add_items(playlist_id, track_ids) return playlist_id ``` This function takes in a list of track IDs and creates a playlist for them. I have a separate function that uses the Search endpoint to find track IDs given a song name and artist name, that part works fine, I just get an error when I try to run this function to create a new playlist with those track IDs. **Output** Full traceback is available here [traceback.txt](https://github.com/user-attachments/files/17924553/traceback.txt) **Environment:** - OS: [e.g. Windows, Mac] - Python version [e.g. 3.7.0] - spotipy version [e.g. 2.12.0] - your IDE (if using any) [e.g. PyCharm, Jupyter Notebook IDE, Google Colab] ``` OS: Ubuntu 24.04.1 LTS Kernel: 6.8.0-48-generic ``` Packages and versions installed in virtual env: ``` certifi==2024.8.30 charset-normalizer==3.4.0 idna==3.10 redis==5.2.0 requests==2.32.3 spotipy==2.24.0 urllib3==2.2.3 ``` Python version ``` Python 3.12.3 ``` **Additional context** Add any other context about the problem here.
kerem 2026-02-28 00:00:53 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

Disregard -- I was passing in text for the playlist description that contained a newline character (\n) and for some reason the API didn't like that. I removed it and it went away.

<!-- gh-comment-id:2501779129 --> @raleighlittles commented on GitHub (Nov 26, 2024): Disregard -- I was passing in text for the playlist description that contained a newline character (`\n`) and for some reason the API didn't like that. I removed it and it went away.
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#690
No description provided.