Delete songs from playlist via Apple Music API

I use

htttps://api.music.apple.com/v1/me/library/playlists/${playlistId}/tracks

to add tracks to a playlist I created.

How do I DELETE tracks from the playlist?

The documentation does not mention a method for this. I have tried calling DELETE methods in various combinations but nothing seems to work.

Is this possible?

Answered by DTS Engineer in 863854022

Before trying to edit a playlist, check and see if the playlist's canEdit attribute indicates that you can edit the playlist. For more information please see LibraryPlaylists.Attributes.

Before trying to edit a playlist, check and see if the playlist's canEdit attribute indicates that you can edit the playlist. For more information please see LibraryPlaylists.Attributes.

Thanks for the response. canEdit=true in my case, so I don't think that is it. Is their documentation on the DELETE method?

This is how I am attempting the deletion:

  payload = {
    "data": [
      {
        "position": 0,
        "type": "library-songs"
      }
    ]
  };

const response = await fetch(url, {
      method: 'DELETE',
      headers: {
        'Authorization': `Bearer ${DEVELOPER_TOKEN}`,
        'Music-User-Token': USER_TOKEN,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(payload)
    });

The USER_Token was generated via:

music.authorize({ scopes: ['library-modify'] });

I can successfully create a playlist and add to it using those tokens, so they should be OK. (this is in node.js)

I can find no documentation for any track deletion API, this code is an approach I have seen in posts around the web, but I do not know if that method is in fact the right approach.

Delete songs from playlist via Apple Music API
 
 
Q