Skip to main content

API test

Best practices

When needing to add a child playlist to the parent playlist, it's best for both the parent and child playlists to have at least one asset to avoid the parent playlist containing only an empty child playlist, which could result in a 404 error when querying the list of contents for the parent playlist.

❌ ** DON'T DO THIS: **

const [playlistA, playlistB] = await Promise.all([
createPlaylist({ name: "A" }),
createPlaylist({ name: "B" }),
]);

await addAssetToPlaylist({
playlistId: playlistA.id,
assetId: playlistB.id,
});

✅ ** DO THIS: **

const [playlistA, playlistB, asset] = await Promise.all([
createPlaylist({ name: "A" }),
createPlaylist({ name: "B" }),
createAsset({ name: "Asset" }),
]);

// adding the asset to the playlists first
await addAssetToPlaylist({
playlistId: playlistA.id,
assetId: asset.id,
});
await addAssetToPlaylist({
playlistId: playlistB.id,
assetId: asset.id,
});

await addAssetToPlaylist({
playlistId: playlistA.id,
assetId: playlistB.id,
});