Trouble with my first api call with postman

hi
I installed xibo 1.8.7 with docker on windows 10
I tried to make a token api call wtih postman. i read the support and different issues and solutions (mca.gaurav85 post) but i have always the same message:
the request is missing a required parameter … check the grant type parameter
kindly suggest.

What’s about ?

Application Code within the 3rd party application
The 3rd party application must obtain an access token which is used when making requests. This is done using the standard oAuth pattern. The specific URL’s for the CMS are shown below:
Service location: http:://YourCMS/services.php

sorry for my very bad english

Could you show me a screenshot of your postman call? The first call should be to access_token, as you need to obtain that and save it before you can use other calls.

I assume you’ve added new application in CMS and the client id and secret are saved in Postman environment?

Perhaps you could have a read through this - 1.8 API Introduction

Should help you get started, if you’d still have issues, please do let me know.

hi

i’m so api because i spent a long time to find where the mistake could be
today, after your reply i look back to your api call through postman post and i got my access token !!!
in the body of the access_token call i didn’t put in the body : client_id, client_secret and grand_type
i thought it was done when your create the environment

so i can go on

thanks for you support

i tried to go on but when i right click on the token i don’t have in the menu set (environement name)>access_token

i have encodeuricomponent and decodeuricompenent but i have a button save response

i suppose it’s not the same version of postman that you used

Hmm, in the top right in Postman, do you have the Environment selected?
If you do, do you have the parameters configured in it?

The only reason why it would not give you an option to set the, in this case access_token, like in my guide is if you don’t have any environment set or at least an environment without any parameters defined in it.

hi

yes i have the environnment selected
i read your post another time and i remember that i did’nt write access-tocken during creation of the environnement because you said you’ll get it further
i added it and it’s fine it works

fine

i thank you for your support

i am new in api and i have so many things to discover
but i have too questions :slight_smile:

first what about the duration of the access_token ? often i coud’nt make call because the time was over
how will i do for it lasts more !!!

second one : i tried to get the time of the cms (very easy) no argument

but i tried to change layout it depends on 2 calls with postman i take the displayid in the GET Display call and in the GET Layout i got the layout id
i can’t see how two link different calls in application to do the change layout call

but i go on reading, testing thinking someone could help me

best regards

Access_token lasts for 1h by default.

You can ensure that you call get access_token before other calls, once we properly sort out our oath2 API library, then I’will encourage everyone to use our wrappers (which will get new tokens when needed) - you could use them as they are already, but there are some big changes coming there.

You mean the changeLayout action?
That requires displayGroupId (either actual display group id or display specific display group id) and layoutId.

You can show me screenshot from postman / code that you have and perhaps I will see what could be wrong there.

hi
thanks for your support
i go slowly i try and sometimes i succeed
i follow the 1.8 Api introduction with postman
i could create a layout
i could upload the file
but i could’nt add the media to the region
you said the playlistid is required but i can’t see it on your screenshot i only see media array

the response says : cannot find playlist what is wrong ?

it’s not very to understand the logic of xibo :

i tried another thing : tried to put text in the layout i just created
i follow your post "how to change text or image through api"
you talk about “edit” but in the layout i just create there’s no widget so :
it put the text in the default layout i follow your post step by step then i wonder as there is no widget it put the text where it can

you talk about improvement soon i hope this kind of manipulation will be easier

thanks for reading me

So you need to use this call to assign media from library to a playlist Swagger UI

as such you need to know the playlistId and of course the mediaId of the media file(s) that you want to assign.

You will want to call GET layout with embed parameter Swagger UI

ie something like
/api/layout?embed=regions,playlists,widgets

Technically you don’t necessarily need widgets there at this point, but it might be good for you to see the full structure.

if you know your layoutId then you can filter by it as well ie say your layoutId is 10 then you can call GET layout like this:

/api/layout?layoutId=10&embed=regions,playlists,widgets

Then it will show you only data about that particular layout.

so you will be looking at structure like this:

"regions": [
            {
                "regionId": 102,
                "layoutId": 50,
                "ownerId": 1,
                "name": "phpunit layout-1",
                "width": "1920.0000",
                "height": "1080.0000",
                "top": "0.0000",
                "left": "0.0000",
                "zIndex": 0,
                "playlists": [
                    {
                        "playlistId": 102,
                        "ownerId": 1,
                        "name": "phpunit layout-1",
                        "tags": [],
                        "widgets": [],
                        "permissions": [],
                        "displayOrder": "1"
                    }
                ],

So you can see in this example the playlistId is 102, let’s say the mediaId that I want to assign has id 14, so the final call in postman to assign that media to that playlist will look like that:

image

If you want to add widgets like text, then you’d use the following call
https://xibo.org.uk/manual/api/#/widget/WidgetTextAdd

Which of course also requires playlistId

Once you have a text widget on a layout (added via API or webUI) then yes you can follow my post in the Edit a Text Widget API - #2 by Peter

hi

thanks for your support

there are things i can do (with your explanation) others i can’t

i tried to do a change layout it doesnt work

i succeed in getting : displaygroupid and layoutid but after i can’t do changelayout withi postman

here are two screenhot

i hope it will help you to help me

best regards

What headers are you passing with that call? I’d expect only Authorization in this case.

The error most likely means that we can’t find displayGroupId = 2 in your CMS, it could be good to check that it exists.

Second call is incorrect I’m afraid, but at least I know what second header you have .

The content-type header is not needed in this case, you should only pass layoutId, changeMode and optionally duration and downloadRequired.
displayGroupId is passed in the path (in the url) as such you do not pass it as parameter in Body.

hi

i didn’t create any displaygroup

the displaygroupid i got it when i did a get display call api

is it wrong ?

Could you post the response of get display call please?

hi

here is the response of get display call :

first part

second part

Right, so the displayGroupId which is display specific displayGroupId is 1
that’s what you should use in the changeLayout action call.

image

If there is no other displays, then displayGroupId = 2 probably does not exist, hence the error you got when you tried to issue an action on it.

i wonder perharps you will need the get layout call

[
{
“layoutId”: 1,
“ownerId”: 1,
“campaignId”: 1,
“backgroundImageId”: null,
“schemaVersion”: 3,
“layout”: “Default Layout”,
“description”: “”,
“backgroundColor”: “#000000”,
“createdDt”: “2018-04-30 19:50:09”,
“modifiedDt”: “2018-04-30 19:51:01”,
“status”: 1,
“retired”: 0,
“backgroundzIndex”: 0,
“width”: 1920,
“height”: 1080,
“displayOrder”: null,
“duration”: 15,
“statusMessage”: null,
“regions”: [
{
“regionId”: 1,
“layoutId”: 1,
“ownerId”: 1,
“name”: “1”,
“width”: “1920.0000”,
“height”: “936.0000”,
“top”: “0.0000”,
“left”: “0.0000”,
“zIndex”: 0,
“playlists”: [
{
“playlistId”: 1,
“ownerId”: 1,
“name”: “”,
“tags”: [],
“widgets”: [],
“permissions”: [],
“displayOrder”: “1”
}
],
“regionOptions”: [],
“permissions”: [],
“displayOrder”: null,
“duration”: “15”,
“tempId”: null
},
{
“regionId”: 2,
“layoutId”: 1,
“ownerId”: 1,
“name”: “2”,
“width”: “432.0000”,
“height”: “129.2308”,
“top”: “940.7885”,
“left”: “1470.4904”,
“zIndex”: 0,
“playlists”: [
{
“playlistId”: 2,
“ownerId”: 1,
“name”: “”,
“tags”: [],
“widgets”: [],
“permissions”: [],
“displayOrder”: “1”
}
],
“regionOptions”: [],
“permissions”: [],
“displayOrder”: null,
“duration”: “10”,
“tempId”: null
}
],
“tags”: “default,imported”,
“permissions”: [],
“campaigns”: [],
“owner”: “xibo_admin”,
“groupsWithPermissions”: null
},
{
“layoutId”: 4,
“ownerId”: 1,
“campaignId”: 4,
“backgroundImageId”: null,
“schemaVersion”: 3,
“layout”: “test”,
“description”: null,
“backgroundColor”: “#000”,
“createdDt”: “2018-05-16 11:15:20”,
“modifiedDt”: “2018-05-16 11:28:22”,
“status”: 1,
“retired”: 0,
“backgroundzIndex”: 0,
“width”: 1920,
“height”: 1080,
“displayOrder”: null,
“duration”: 5,
“statusMessage”: null,
“regions”: [
{
“regionId”: 5,
“layoutId”: 4,
“ownerId”: 1,
“name”: “test-1”,
“width”: “1920.0000”,
“height”: “1080.0000”,
“top”: “0.0000”,
“left”: “0.0000”,
“zIndex”: 0,
“playlists”: [
{
“playlistId”: 5,
“ownerId”: 1,
“name”: “test-1”,
“tags”: [],
“widgets”: [],
“permissions”: [],
“displayOrder”: “1”
}
],
“regionOptions”: [
{
“regionId”: 5,
“option”: “loop”,
“value”: “1”
},
{
“regionId”: 5,
“option”: “transitionDirection”,
“value”: “N”
},
{
“regionId”: 5,
“option”: “transitionDuration”,
“value”: null
},
{
“regionId”: 5,
“option”: “transitionType”,
“value”: null
}
],
“permissions”: [],
“displayOrder”: null,
“duration”: “5”,
“tempId”: null
}
],
“tags”: null,
“permissions”: [],
“campaigns”: [],
“owner”: “xibo_admin”,
“groupsWithPermissions”: null
},
{
“layoutId”: 5,
“ownerId”: 1,
“campaignId”: 5,
“backgroundImageId”: null,
“schemaVersion”: 3,
“layout”: “video”,
“description”: null,
“backgroundColor”: “#000”,
“createdDt”: “2018-05-16 06:50:42”,
“modifiedDt”: “2018-05-16 06:56:58”,
“status”: 1,
“retired”: 0,
“backgroundzIndex”: 0,
“width”: 1920,
“height”: 1080,
“displayOrder”: null,
“duration”: 17,
“statusMessage”: null,
“regions”: [
{
“regionId”: 6,
“layoutId”: 5,
“ownerId”: 1,
“name”: “video-1”,
“width”: “1920.0000”,
“height”: “1080.0000”,
“top”: “0.0000”,
“left”: “0.0000”,
“zIndex”: 0,
“playlists”: [
{
“playlistId”: 6,
“ownerId”: 1,
“name”: “video-1”,
“tags”: [],
“widgets”: [],
“permissions”: [],
“displayOrder”: “1”
}
],
“regionOptions”: [],
“permissions”: [],
“displayOrder”: null,
“duration”: “17”,
“tempId”: null
}
],
“tags”: null,
“permissions”: [],
“campaigns”: [],
“owner”: “xibo_admin”,
“groupsWithPermissions”: null
},
{
“layoutId”: 6,
“ownerId”: 1,
“campaignId”: 6,
“backgroundImageId”: null,
“schemaVersion”: 3,
“layout”: “video 2”,
“description”: null,
“backgroundColor”: “#000”,
“createdDt”: “2018-05-17 07:31:51”,
“modifiedDt”: “2018-05-17 07:33:24”,
“status”: 1,
“retired”: 0,
“backgroundzIndex”: 0,
“width”: 1920,
“height”: 1080,
“displayOrder”: null,
“duration”: 609,
“statusMessage”: null,
“regions”: [
{
“regionId”: 7,
“layoutId”: 6,
“ownerId”: 1,
“name”: “video-1”,
“width”: “1920.0000”,
“height”: “1080.0000”,
“top”: “0.0000”,
“left”: “0.0000”,
“zIndex”: 0,
“playlists”: [
{
“playlistId”: 7,
“ownerId”: 1,
“name”: “video-1”,
“tags”: [],
“widgets”: [],
“permissions”: [],
“displayOrder”: “1”
}
],
“regionOptions”: [],
“permissions”: [],
“displayOrder”: null,
“duration”: “609”,
“tempId”: null
}
],
“tags”: null,
“permissions”: [],
“campaigns”: [],
“owner”: “xibo_admin”,
“groupsWithPermissions”: null
}
]

thanks for your support

You have layouts with id 1,4,5,6 and you were using layoutId 6 in the call so that’s fine.

The problem is, as I mentioned in my previous post the displayGroupId

You should use 1 while you were using 2, which does not exist.

hi

thanks for your answer but i never used displaygroupid=2

i think i’m lost in the call post action change layout (the way to use and where to use the parameters)

i would appreciate like you did different screenshots to compare to the way i do

best regards

So this is the call you posted

The displayGroupId is passed in the path of the call ie
/displaygroup/{displayGroupId}/action/changeLayout

You do have 2 there ie you were trying to post that action on displayGroupId = 2, which does not exist.
As such you want to change the 2 to 1 in the path of your call.

hi

it’s true i can see a 2 in the path but as i used displaygroupid = 1 i think this would be replaced

why the url come with 2 in the swagger file and not like you wrote it ?

i tried and i get this message :

Do not provide displayGroupId as a parameter in body, it is in the path already. (you it misspelled as well, but it should not be there in the first place)

Again this is POST call you do not want to use content type x-www-form-urlencoded, you want to use form-data and only one header with authorization.

The test API collection from my API introduction guide has that call with correct parameters.

Obviously you need to adjust parameters like layoutId or displayGroupId from the ones in the collection you’ve imported - as such yes in the imported collection may use different Ids than the ones you have in your CMS - I don’t see how could I ensure that it would work on all possible CMS Instances without any changes.

The test api collection from my guide is there as an example and should be treated as such.