[GH-ISSUE #550] Can't start playback #328

Closed
opened 2026-02-27 23:22:02 +03:00 by kerem · 5 comments
Owner

Originally created by @glebliutsko on GitHub (Jul 28, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/550

Describe the bug
Can't start playback

Your code

oauth = SpotifyOAuth(
    client_id=client_conf['client_id'],
    client_secret=client_conf['client_secret'],
    redirect_uri='http://localhost:8080/',
    scope='user-modify-playback-state app-remote-control streaming user-read-playback-state',
    cache_path='./auth'
)
sp = Spotify(oauth_manager=oauth)

sp.start_playback(context_uri='spotify:playlist:6mf5APVavd17vvPWzxRaq8', offset=5)

Expected behavior
Start playback

Output


>>> sp.start_playback(context_uri='spotify:playlist:6mf5APVavd17vvPWzxRaq8', offset=5)
HTTP Error for PUT to https://api.spotify.com/v1/me/player/play returned 400 due to Malformed json
Traceback (most recent call last):
  File "/home/gleb/programing/python/sporofy/venv/lib/python3.8/site-packages/spotipy/client.py", line 175, in _internal_call
    response.raise_for_status()
  File "/home/gleb/programing/python/sporofy/venv/lib/python3.8/site-packages/requests/models.py", line 941, 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/me/player/play
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/gleb/programing/python/sporofy/venv/lib/python3.8/site-packages/spotipy/client.py", line 1330, in start_playback
    return self._put(
  File "/home/gleb/programing/python/sporofy/venv/lib/python3.8/site-packages/spotipy/client.py", line 225, in _put
    return self._internal_call("PUT", url, payload, kwargs)
  File "/home/gleb/programing/python/sporofy/venv/lib/python3.8/site-packages/spotipy/client.py", line 186, in _internal_call
    raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/me/player/play:
 Malformed json

Environment:

  • OS: Arch Linux
  • Python version 3.8.4
  • spotipy version 2.13.0
  • IDE PyCharm
Originally created by @glebliutsko on GitHub (Jul 28, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/550 **Describe the bug** Can't start playback **Your code** ```python oauth = SpotifyOAuth( client_id=client_conf['client_id'], client_secret=client_conf['client_secret'], redirect_uri='http://localhost:8080/', scope='user-modify-playback-state app-remote-control streaming user-read-playback-state', cache_path='./auth' ) sp = Spotify(oauth_manager=oauth) sp.start_playback(context_uri='spotify:playlist:6mf5APVavd17vvPWzxRaq8', offset=5) ``` **Expected behavior** Start playback **Output** ``` >>> sp.start_playback(context_uri='spotify:playlist:6mf5APVavd17vvPWzxRaq8', offset=5) HTTP Error for PUT to https://api.spotify.com/v1/me/player/play returned 400 due to Malformed json Traceback (most recent call last): File "/home/gleb/programing/python/sporofy/venv/lib/python3.8/site-packages/spotipy/client.py", line 175, in _internal_call response.raise_for_status() File "/home/gleb/programing/python/sporofy/venv/lib/python3.8/site-packages/requests/models.py", line 941, 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/me/player/play During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<input>", line 1, in <module> File "/home/gleb/programing/python/sporofy/venv/lib/python3.8/site-packages/spotipy/client.py", line 1330, in start_playback return self._put( File "/home/gleb/programing/python/sporofy/venv/lib/python3.8/site-packages/spotipy/client.py", line 225, in _put return self._internal_call("PUT", url, payload, kwargs) File "/home/gleb/programing/python/sporofy/venv/lib/python3.8/site-packages/spotipy/client.py", line 186, in _internal_call raise SpotifyException( spotipy.exceptions.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/me/player/play: Malformed json ``` **Environment:** - OS: Arch Linux - Python version 3.8.4 - spotipy version 2.13.0 - IDE PyCharm
kerem 2026-02-27 23:22:02 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@stephanebruckert commented on GitHub (Jul 29, 2020):

I see the following, so I'm wondering if client_conf['client_secret'] works?

NameError: name 'spotify_client' is not defined

<!-- gh-comment-id:665479994 --> @stephanebruckert commented on GitHub (Jul 29, 2020): I see the following, so I'm wondering if `client_conf['client_secret']` works? > NameError: name 'spotify_client' is not defined
Author
Owner

@glebliutsko commented on GitHub (Jul 29, 2020):

I see the following, so I'm wondering if client_conf['client_secret'] works?

NameError: name 'spotify_client' is not defined

Sorry, I copied the extra. Сorrected.

<!-- gh-comment-id:665519679 --> @glebliutsko commented on GitHub (Jul 29, 2020): > I see the following, so I'm wondering if `client_conf['client_secret']` works? > > > NameError: name 'spotify_client' is not defined > Sorry, I copied the extra. Сorrected.
Author
Owner

@stephanebruckert commented on GitHub (Jul 29, 2020):

According to https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/ it looks like offset should be an object. Try

sp.start_playback(context_uri='spotify:playlist:6mf5APVavd17vvPWzxRaq8', offset={"position": 5})
<!-- gh-comment-id:665527760 --> @stephanebruckert commented on GitHub (Jul 29, 2020): According to https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/ it looks like `offset` should be an object. Try sp.start_playback(context_uri='spotify:playlist:6mf5APVavd17vvPWzxRaq8', offset={"position": 5})
Author
Owner

@glebliutsko commented on GitHub (Jul 29, 2020):

It works. Thank.

- offset - offset into context by index or track

Then the documentation must be corrected

<!-- gh-comment-id:665530808 --> @glebliutsko commented on GitHub (Jul 29, 2020): It works. Thank. > \- offset - offset into context by index or track Then the documentation must be corrected
Author
Owner

@stephanebruckert commented on GitHub (Jul 29, 2020):

@glebliutsko if you get a chance feel free to open a PR to improve the doc

<!-- gh-comment-id:665541186 --> @stephanebruckert commented on GitHub (Jul 29, 2020): @glebliutsko if you get a chance feel free to open a PR to improve the doc
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#328
No description provided.