I can add a playlist to a user's library with the following code:
const postOptions = {
method: "POST",
url: `https://api.music.apple.com/v1/me/library/playlists`,
headers: {
Authorization: "Bearer " + token,
"Music-User-Token": appleMusicUserToken,
"Content-Type": "application/json"
},
data: {
attributes: {
description: "Amazing playlist!",
name: "amazingPlaylist"
}
}
};
const { data } = await axios(postOptions);
At this point, the playlist is not public, and there is no attributes => playParams => globalId key/value shown in the response or in future GETs of the playlist.
If I turn on "Show on My Profile and in Search" in Music on an iPhone, this adds the globalId.
The globalID is also added, when, in iTunes, the more icon is clicked and any of the Share Playlist options are clicked. Interestingly, you don't need to do anything else. For example, just selecting Share Playlist => Copy Link will add the globalID to the playlist.
What I want to do:
Ideally, I'd like to somehow have the globalID created when the playlist is created, or be able to perform some API call that will do this after creation, so as to prevent the user from having to do this on their device as an additional step. As the user is initiating this action, and they have already authorized the app, this shouldn't be a privacy or security issue.
Thanks in advance for any ideas toward helping me get this working.