Is there some way to assign subplaylist widget to layout with API?

Hi,everybody
I’m using xibo-cms 2.0.4.

Is there some way to assign subplaylist widget to layout with API?

I know how to assign library media to layout by using 「/playlist/library/assign/:id」 .
But I can’t find how to assign subplaylist to layout.

Is that possible?
Or, am I forgetting somthing about that?

Similar to adding other non-media based widgets, you can call the following:
POST /api/playlist/widget/{widgetType}/{playlistId}

ie if you want to add subplaylist widget then call:
POST /api/playlist/widget/subplaylist/{playlistId}

Then you will need to edit it with:
EDIT /api/playlist/widget/{widgetId}

passing at least subPlaylistId int array, in Postman it would look something like this:

image

The spots, remainder (drop, repeat, none) and arrangement (even, roundrobin, none) are all optional settings - we will make sure to better show that in the API documentation with the next release.

1 Like

Hi,Peter.
Thank you for comment.

I confirmed the behavior the method that you said enabled it.
And it worked!

Thank you for quick and detailed answer.

@Peter
I am trying to make a call to add a playlist to a subplaylist widget but not quite getting it to work correctly and not sure what I’m missing. I get a response of:
“message”: “Please select at least 1 Playlist to embed”
“property”: “subPlaylistId”

[Endpoint=https://rbmvelocity.xibo.cloud/api/playlist/widget/96, Method=PUT]

–rbmvelocity
Content-Disposition: form-data; name=“subPlaylistId[]”

111
–rbmvelocity
Content-Disposition: form-data; name=“arrangement[]”

roundrobin
–rbmvelocity
Content-Disposition: form-data; name=“subPlaylistIdSpots[]”

1
–rbmvelocity
Content-Disposition: form-data; name=“subPlaylistIdSpotLength[]”

1
–rbmvelocity
Content-Disposition: form-data; name=“subPlaylistIdSpotFill[]”

repeat
–rbmvelocity–

You need to use x-www-form-urlencoded for a PUT request, you’re using multipart form data there.

Gah,
Thanks I got that working.
How can I specify multiples in the array? (Not sure on the syntax needed)
subPlaylistId[]=123,124
doesn’t seem to add another row in the subplaylist as I would expect.

Ignore that questions I found it.

For others that come across this, the answer is this:

subPlaylistId[]=123&subPlaylistId[]=124

Pleased you found it and pleased to have helped! Good luck with the rest of your project

Sorry to keep this alive…
I am getting a new error when trying to add playlists into the subplaylist and the error doesnt seem to have enough information.

“Cannot add the same SubPlaylist twice.”
But the IDs I am adding are different. I noticed the same error in the UI though too. So I am sure I’m missing something simple…

I tried testing it a bit more, and it errors on 2 different playlists with that error while i can add others without issue. (including the one that was indeed added first.)

Do you have them nested?
So are there Playlists on your Sub-Playlist Playlists?

It sounds like you’ve got a loop going on :ferris_wheel:

I do,
Maybe I just don’t know the best way to structure to get the results I’m looking for.

7 PlaylistWithSubPlaylist of: 5PlaylistWithSubPlaylist, 6PlaylistWithSubPlaylist

6 PlaylistWithSubPlaylist of: 3PlaylistWithImages, 4PlaylistWithImages
4 PlaylistWithImages
3 PlaylistWithImages

5 PlaylistWithSubPlaylist of: 1PlaylistWithImages, 2PlaylistWithImages
2 PlaylistWithImages
1 PlaylistWithImages

The reasoning behind trying to structure this way is for the reusability and how we have have images grouped together. I hope that makes sense… If there is another way to accomplish this please let me know. Thank you.

Having Playlists on Playlists is fine and is how we hope you’ll use the system - the only thing you can’t do is have the same Playlist again in the chain. If you remove that link you’ll be fine.

So you can’t have:
A -> B -> C -> B -> D

Because when we try to join them together, B has C on it, which has B on it, which has C on it, which has B on it, etc :smile: - i.e. an endless loop.

Thanks, that makes sense. I dont believe we have any loop happening like that but I’ll take another look to be sure.

OK sure - I double checked the error message and I think it can only happen when there is a loop like that. It isn’t too easy to spot sometimes as you have to go through each Sub-Playlist Widget.

Hope you find it!

I took another look and don’t seem to have any loops happening.
I ran a troubleshoot session and here were the errors i got but im not certain what exactly i did:

4542 0f5a674 2020-02-05 21:08 WEB PUT ERROR /playlist/widget/153 SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘162-147-2’ for key ‘PRIMARY’ Exception Type: PDOException
4545 2fc56b4 2020-02-05 21:08 WEB PUT ERROR /playlist/widget/153 SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘162-150-2’ for key ‘PRIMARY’ Exception Type: PDOException
4548 8c1c8b9 2020-02-05 21:09 WEB PUT ERROR /playlist/widget/153 SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘162-153-2’ for key ‘PRIMARY’ Exception Type: PDOException
4551 746fef1 2020-02-05 21:09 WEB PUT ERROR /playlist/widget/153 SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘162-144-2’ for key ‘PRIMARY’ Exception Type: PDOException

Are you saying the errors you have in the log happen when the above message appears in the response?

Or is this now a new error?

We’d need a log with debugging switched on I think - maybe even with your CMS in Test mode - as the SQL exception doesn’t tell us enough on its own.

Yes sorry, this is what I can see in the log when the error happens. (I was able to recreate it in the UI)
I followed the “Troubleshoot” to turn debugging on and then recreate the error and download the zip file and this is what I pulled from there as well as the “Logs” tab. I didn’t try switching the CMS to Test mode tho. Not sure if that gives more information or not.
It does seem like it doesn’t like specific playlists but they have nothing in common so that part confused me a bit.

Sorry - did you mean to attach some logs?

I think that i’ll need to see what you’ve got to diagnose whats happening - its very hard to tell from the description/error messages. Do you have a link you can share?

It is suggesting that there is a loop - Playlist with the ID 147 appears twice in the Widgets for Playlist with the ID 162.

New to XIBO with a basic question on this topic. I have a layout with a default full screen region (1080p). I’d like to link a playlist to this layout/region.

From this thread, the first action is to add the subplaylist widget using the following:
POST /api/playlist/widget/subplaylist/{playlistId}

For this request, what is the value to used for the playlistID? Is there a default playlistid created in region 0 of the layout that should be used? Would I need to search the layouts (e.g. by layout name) to find the current value of the playlistID for region 0 before the request to add the subplsylist widget?