1.8 Alpha swagger.json

I am attempting to read the swagger.json file with Swagger UI. When I enter in the location of the json file and also the API key all I get is a message saying:

fetching resource list: http://localhost/xibo18alpha/web/swagger.json

I have also tried this with HTTPS and got the same.

In the meantime, can someone explain to me how the procedure to register an application has changed? I noticed that the tables are completely different in the database, everything appears to be completely different and our previous method of registering our CMS through the API is not working with 1.8.

Also note that when I tried swaggers online json editor I got this error:


The page crashed Chrome :open_mouth:

There appears to be a few issues with the latest Swagger File I pushed to the repository - not sure exactly what they are at the moment (2 hours in and counting!)

Adding an application is essentially the same - you get a form asking for your Application Name and Redirect URL - are you seeing something different that before?

I’ve just merged in a fix for the swagger.json file - there are some things missing that I have had to remove to get it to work… but I will get those put back in when I work out how to do them.

You don’t need to enter an API KEY as swagger-ui doesn’t yet support “try me” with accessCode oauth (which is what Xibo uses).

Dan,

I didn’t think I would need an API key to access the swagger.json file. They Swagger UI did not appear to do anything without it. I will use something that supports oAuth. Thank you for the quick reply.

That is because the swagger.json file in the repository was broken - sorry about that. I’ve fixed the file which should mean the documentation loads. I will also be generating static documentation for the final release - but the swagger-ui docs are nice as you can explore what is sent from and to.

oAuth
A note on oAuth - we are still using oAuth, so your client implementation should not be effected at all, apart from the end points changing. There are a new set of endpoints as described in the document (and the tables have changed in Xibo so you will need to register a new application to get an API key).

The end points are:

  • /api/application/authorize
  • /api/authorize/access_token
  • /api/[xxxx]

Dan,

Thank you for the quick response and information. That will surely help move us along. :grinning:

I moved 4 posts to a new topic: Connecting to the 1.8 API

I am totally new to swagger.json files. So in the mean time, if you wouldn’t mind, just so I can try to understand them a bit, would you mind giving me the syntax example to say return all media that belongs to a user from the media library, via the api?

So it depends what you are using to make your request - for example with curl it would look like:

curl -X GET --header "Accept: application/json" "http://<<your url>>/api/library?access_token=<<token>>"

You could also provide the access_token via the Authorization header - for example with Guzzle:

$client = new \GuzzelHttp\Client();
$response = $client->get('http://<<your url>>/api/library', ['headers' => ['Authorization' => '<<token>>']]]);

The response will be json as shown in the swagger example - i.e. an array of media objects.

1 Like

Thank you for the two examples. The Guzzel example verified I was on the right track.

I Needed to add some extra code to the .htaccess file to get the Header locations to work on apache.

Now when I make a GET request I get a response, but I don’t seem to get the correct response. For example, when I request the media of the library. I use the /api/library to return all of the media. I have, for testing, a single jpg file in the media library.

Code:

$client = new Client();
$request = $client->get('https://DOMAIN.com/xibo18alpha/web/api/library', 
	['Authorization'=>['access_token'=>'Bearer YbtJk476DgDHQ6TPBSfzIAon7NVmswNaXBUSHeIS']]
	);

var_dump of response:

object(Guzzle\Http\Message\Response)[33]
  protected 'body' => 
    object(Guzzle\Http\EntityBody)[32]
      protected 'contentEncoding' => boolean false
      protected 'rewindFunction' => null
      protected 'stream' => resource(60, stream)
      protected 'size' => null
      protected 'cache' => 
        array (size=9)
          'wrapper_type' => string 'PHP' (length=3)
          'stream_type' => string 'TEMP' (length=4)
          'mode' => string 'w+b' (length=3)
          'unread_bytes' => int 0
          'seekable' => boolean true
          'uri' => string 'php://temp' (length=10)
          'is_local' => boolean true
          'is_readable' => boolean true
          'is_writable' => boolean true
      protected 'customData' => 
        array (size=1)
          'default' => boolean true
  protected 'reasonPhrase' => string 'OK' (length=2)
  protected 'statusCode' => int 200
  protected 'info' => 
    array (size=26)
      'url' => string 'https://DOMAIN.com/xibo18alpha/web/api/library' (length=51)
      'content_type' => string 'application/json' (length=16)
      'http_code' => int 200
      'header_size' => int 321
      'request_size' => int 181
      'filetime' => int -1
      'ssl_verify_result' => int 0
      'redirect_count' => int 0
      'total_time' => float 0.578
      'namelookup_time' => float 0
      'connect_time' => float 0
      'pretransfer_time' => float 0.063
      'size_upload' => float 0
      'size_download' => float 1031
      'speed_download' => float 1783
      'speed_upload' => float 0
      'download_content_length' => float 1031
      'upload_content_length' => float 0
      'starttransfer_time' => float 0.578
      'redirect_time' => float 0
      'redirect_url' => string '' (length=0)
      'primary_ip' => string '127.0.0.1' (length=9)
      'certinfo' => 
        array (size=0)
          empty
      'primary_port' => int 443
      'local_ip' => string '127.0.0.1' (length=9)
      'local_port' => int 57480
  protected 'effectiveUrl' => string 'https://DOMAIN.com/xibo18alpha/web/api/library' (length=51)
  protected 'headers' => 
    object(Guzzle\Http\Message\Header\HeaderCollection)[36]
      protected 'headers' => 
        array (size=8)
          'date' => 
            object(Guzzle\Http\Message\Header)[37]
              ...
          'server' => 
            object(Guzzle\Http\Message\Header)[38]
              ...
          'vary' => 
            object(Guzzle\Http\Message\Header)[39]
              ...
          'x-powered-by' => 
            object(Guzzle\Http\Message\Header)[40]
              ...
          'x-total-count' => 
            object(Guzzle\Http\Message\Header)[41]
              ...
          'link' => 
            object(Guzzle\Http\Message\Header\Link)[42]
              ...
          'content-length' => 
            object(Guzzle\Http\Message\Header)[43]
              ...
          'content-type' => 
            object(Guzzle\Http\Message\Header)[44]
              ...
  protected 'headerFactory' => 
    object(Guzzle\Http\Message\Header\HeaderFactory)[35]
      protected 'mapping' => 
        array (size=2)
          'cache-control' => string 'Guzzle\Http\Message\Header\CacheControl' (length=39)
          'link' => string 'Guzzle\Http\Message\Header\Link' (length=31)
  protected 'params' => 
    object(Guzzle\Common\Collection)[34]
      protected 'data' => 
        array (size=0)
          empty
  protected 'protocol' => string 'HTTP' (length=4)
  protected 'protocolVersion' => string '1.1' (length=3)

CMS Log:

logId,runNo,logDate,channel,page,function,message,display.display,type
49,29f83aa,"2015-09-23 22:06:34",API,/library,GET,"Loading 1. All Objects = 0",,DEBUG
50,e4b0b97,"2015-09-23 22:07:10",API,/library,GET,"Loading 1. All Objects = 0",,DEBUG
51,2471c8c,"2015-09-23 22:08:14",API,/library,GET,"Loading 1. All Objects = 0",,DEBUG
52,e99e694,"2015-09-23 22:09:27",API,/library,GET,"Loading 1. All Objects = 0",,DEBUG
53,720f2d9,"2015-09-23 22:10:13",API,/library,GET,"Loading 1. All Objects = 0",,DEBUG
54,a32fa60,"2015-09-23 22:11:08",API,/library,GET,"Loading 1. All Objects = 0",,DEBUG
55,0b54237,"2015-09-23 22:11:28",API,/library,GET,"Loading 1. All Objects = 0",,DEBUG
56,b9f5765,"2015-09-23 22:12:43",WEB,/log,GET,"Request to redirect to login. Ajax = 1",,DEBUG
57,511025e,"2015-09-23 22:12:50",WEB,/log,GET,"Request to redirect to login. Ajax = 1",,DEBUG
58,25c509c,"2015-09-23 22:12:53",WEB,/log/view,GET,"Request to redirect to login. Ajax = 0",,DEBUG
59,e6a0923,"2015-09-23 22:12:56",WEB,/login,POST,"Login with username xibo_admin",,DEBUG
60,e6a0923,"2015-09-23 22:12:56",WEB,/login,POST,"Password checked out OK",,DEBUG
61,e6a0923,"2015-09-23 22:12:56",WEB,/login,POST,"xibo_admin user logged in.",,INFO
62,e6a0923,"2015-09-23 22:12:56",WEB,/login,POST,"Redirect to /log/view",,DEBUG
63,2a8c5cb,"2015-09-23 22:13:00",WEB,/login,POST,"Login with username xibo_admin",,DEBUG
64,2a8c5cb,"2015-09-23 22:13:00",WEB,/login,POST,"Password checked out OK",,DEBUG
65,2a8c5cb,"2015-09-23 22:13:00",WEB,/login,POST,"xibo_admin user logged in.",,INFO
66,2a8c5cb,"2015-09-23 22:13:00",WEB,/login,POST,"Redirect to /xibo18alpha/web/",,DEBUG
67,5132cdc,"2015-09-23 22:13:01",WEB,/,GET,"Loading 1. All Objects = 0",,DEBUG
68,5132cdc,"2015-09-23 22:13:01",WEB,/,GET,"Showing the homepage: 29",,DEBUG
69,bf7e692,"2015-09-23 22:13:01",WEB,/dashboard/status,GET,"Loading 1. All Objects = 0",,DEBUG
70,c2794c5,"2015-09-23 22:13:06",WEB,/log/view,GET,"Loading 1. All Objects = 0",,DEBUG
71,6b70257,"2015-09-23 22:13:07",WEB,/log,GET,"Loading 1. All Objects = 0",,DEBUG
72,30026f5,"2015-09-23 22:13:41",API,/library,GET,"Loading 1. All Objects = 0",,DEBUG
73,9cbb881,"2015-09-23 22:13:44",WEB,/log/view,GET,"Loading 1. All Objects = 0",,DEBUG
74,6b6f55a,"2015-09-23 22:13:45",WEB,/log,GET,"Loading 1. All Objects = 0",,DEBUG
75,9e23dce,"2015-09-23 22:14:01",WEB,/log,GET,"Loading 1. All Objects = 0",,DEBUG
76,931b70e,"2015-09-23 22:14:43",WEB,/fault/view,GET,"Loading 1. All Objects = 0",,DEBUG
77,defbe0b,"2015-09-23 22:14:47",WEB,/fault/collect,GET,"Loading 1. All Objects = 0",,DEBUG
78,65b7725,"2015-09-23 22:15:16",WEB,/fault/collect,GET,"Loading 1. All Objects = 0",,DEBUG

What do you get if you do?

echo $response->getBody();

Everything you’ve done looks OK - as does the CMS log I think

1 Like

Well now… that makes since. And it works. Thank you for pointing that out.

1 Like