Assigning media to playlist using API no longer works on Xibo 3.0?

Hello,

I am trying to assign a media to a playlist automatically created inside of a layout.

Here is the request I’m sending
image

I have tried both with postman and the PHP oauth2 api.
The media id 25 does exist, aswell as the playlist id15.
And I am sure that everything else is correct since it was working on a Xibo 2.0.5 CMS and is still working for all the other requests, such as creating the layout.

Do you have any idea of what might cause this error ?
Thanks.

It’s not really in my wheelhouse, but the API docs say that the media parameter should be an integer array, and you’re passing in a single integer, so that’s likely the issue.

https://xibo.org.uk/manual/api/#/playlist/playlistLibraryAssign

I don’t believe that’s the problem.

I am passing the media as an array using the PHP oauth2 API and I still get the same error. I haven’t changed anything to my code since the version 2 and it was working back then.

I’ve had one of our dev team check and it works as expected for them using Postman as follows.

The media ID must be an integer array, and it shouldn’t be passed as a parameter but should be part of the body:

image

The input validation on version 2 is more forgiving and may validate your original request, but it’s not how it should be, and the validation on v3 is correct in rejecting that.

Hi Alex,

Sorry for the delay.

I’ve managed to get it working using Postman.

However I still can’t figure out how to make it work using the PHP API…

Here is the call I’m making

$xPlaylist = (new \Xibo\OAuth2\Client\Entity\XiboPlaylist($this->EP));
$xPlaylistAssign = $xPlaylist->assign([$mediaXiboId], $layoutDurations, $xLayoutChecked->regions[0]->regionPlaylist->playlistId);

In this example, mediaXiboId is equal to 24 but I pass it as an array in the function argument, layoutDurations is equal to [25] and the playlistId is equal to 7.
Yet I’m still getting the error mentionned above.

I’ve also tried to update the CMS to the 3.0.4 version but it didn’t help.

Could you try it out using the PHP API to see if you encounter the same issue ?

Thanks.

I’ve made some tests and the problem is related to the “duration” parameter. My request works I comment it out in the XiboPlaylist.php file like so :

$response = $this->doPost(‘/playlist/library/assign/’ . $playlistId, [
‘media’ => $media,
//‘duration’ => $duration
]);

But obviously this is not a good fix since I still need to give my widget a duration.

Having this temporary fix, I tried to publish the layout using the API aswell and nothing is happening. There no error returned…

$xLayoutPublish = (new \Xibo\OAuth2\Client\Entity\XiboLayout($this->EP))->publish($xLayoutChecked->parentId);

Am I doing something wrong ? Again, this was all working fine using a v2 CMS

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.