Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playlists.removeItems uses wrong format in body of request #241

Open
liam-k opened this issue Oct 6, 2023 · 1 comment
Open

playlists.removeItems uses wrong format in body of request #241

liam-k opened this issue Oct 6, 2023 · 1 comment
Milestone

Comments

@liam-k
Copy link

liam-k commented Oct 6, 2023

Bug Report

The PlaylistManager.removeItems() method uses a deprecated format for the request.

What i expected:

The DELETE request to succeed and the track to be deleted.

What actually happened:

I get the error message
SpotifyAPIError: {"error":{"status":400,"message":"JSON body doesn't conform to specification"}}

Upon investigating I found that the call looks like this: 

      url: 'https://api.spotify.com/v1/playlists/16N...Unimd/tracks',
      method: 'delete',
      data: '{"uris":[{"uri":"spotify:track:2wwXXU...5"}]}' <--- WRONG SYNTAX HERE

Note the "uris" before the array of track objects.

The Spotify API docs describe the API as expecting this format:

"tracks": [ { "uri": "string" } ],
(Source)

Which causes the issue.

To reproduce this bug:

Create a client (here I do it with an existing refresh token):

import * as Spotify from "spotify-api.js"
    const client = await Spotify.Client.create({
        token: {
            clientID: SPOTIFY_CLIENT_ID,
            clientSecret: SPOTIFY_CLIENT_SECRET,
            refreshToken: refresh_token
        }
    });

Then use the removeItems method to make the DELETE request to the API:

await client.playlists.removeItems(playlist.spotify_uri, [`spotify:track:${song_uri}`])
  • Library Version: 9.2.5

Anyway, thanks for your work! It’s made my life easier in the instances where it does work.

@scientific-dev
Copy link
Member

There are no developers working on this project at this moment so, it will take few months (2 or 3) for me to restart this (because of my personal problems). If you could, you can do a pull request fixing this issue.

@abh80 abh80 added this to the v10 milestone Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants