SpotifyAPI-NET icon indicating copy to clipboard operation
SpotifyAPI-NET copied to clipboard

BUG: PlaylistClient.ReplaceItems() checking for HttpStatusCode.Created when Spotify returns HttpStatusCode.OK

Open goldfish1974 opened this issue 9 months ago • 1 comments

When using PlayListClient.ReplaceItems(playlist.Id, new PlaylistReplaceItemsRequest(uris),

the return code from the ReplaceItems returns false when the HttpResponse is OK from the Spotify endpoint. In the code, it makes the assumption that calling ReplaceItems returns created whereas the documentation, and in practice it returns OK.

As a result, you cannot trust the return value but must resort to looking at SpotifyClient.LastResponse.StatusCode.

The bug is here:

  • https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/1281ce8732b10fa2c3e7b264c9cc33a983a7ab60/SpotifyAPI.Web/Clients/PlaylistsClient.cs#L105

and the Spotify Documentation for the value return values is here:

  • https://developer.spotify.com/documentation/web-api/reference/reorder-or-replace-playlists-tracks

To fix the issue, most likely the line mentioning where the bug is just needs to be updated to OK.

goldfish1974 avatar May 14 '24 05:05 goldfish1974