Spotify web api : event/item_ready or resume queries error 400

Viewed 29

This problem made me crazy, I have to present my app in 2 days, today morning everything was working well, then after lunch, without touching anything I have an event error and my app doen't work anymore this is very very frustrating.

The errors happens when I call the Play endpoint of the spotify Api : https://developer.spotify.com/console/put-play/?device_id=&body=%7B"uris"%3A%5B"spotify%3Atrack%3A7fODjB7BrQTGqh0hogW6XD"%5D%7D

by this simple code :

$("#playSong").click(()=> {
    const deviceId = sessionStorage.getItem("deviceId")
    $.ajax({
        url: "https://api.spotify.com/v1/me/player/play?device_id="+ deviceId,
        type: "put",
        data: JSON.stringify({
            uris : ["spotify:track:0adsXJdRMoumQY1ECzEjWf"]
        }),
        headers: {
            "Content-Type":"application/json" ,
            Authorization: "Bearer " + sessionStorage.getItem("idPlateforme")
        }
    })
})

Token and deviceId are correct and working fine.

The query above returns a success response, though it seems that the web playback sdk sends internally 2 queries that returns 400 not every time

the first query :

https://cpapi.spotify.com/v1/client/90f40750108390a7ed2b62af9e94e58a4763bd15/event/item_ready

with these datas :

{"timestamp":1662798866395,"player_state":{"playback_id":"454eba51905ada7d8e086bda7726f6d2","duration":278181,"current_position":0,"paused":false,"playbackQuality":{"hifi_status":"NONE","audio_quality":"VERY_HIGH"}},"playback_descriptor_id":"CIDQDxANGgVBVURJTw==","initial_loading_stats":{}}

Its error message is this :

Playback updates are only acceptable once the playback has started

The second one which also returns 400 error :

https://cpapi.spotify.com/v1/client/90f40750108390a7ed2b62af9e94e58a4763bd15/event/resume

with datas :

{"timestamp":1662798867712,"player_state":{"playback_id":"454eba51905ada7d8e086bda7726f6d2","duration":278229,"current_position":0,"paused":false,"playbackQuality":{"hifi_status":"NONE","audio_quality":"VERY_HIGH"}},"playback_descriptor_id":"CIDQDxANGgVBVURJTw=="}

everything was tested on a simple HTML page like the example here on all known browsers : https://developer.spotify.com/documentation/web-playback-sdk/quick-start/

and still doesn't work on any

I know it's nothing to do with MY code, a possible bug ?

Please I need help

my first post on stackoverflow btw

0 Answers
Related