Difficulty: expert
Content
Learning Objectives
After reading this article, you’ll be able to:
- test Workplace APIs
Testing the API: examples
It's possible to try out/test the Workplace API. Depending on the request, you might need to fill in some information first.
Below examples mention “location ID”. Selecting a location on https://go.cobundu.com/ will show the Reference, e.g. "Meeting Room 1". But in the Workplace back-end, each location has a unique location ID.
Info
Location ID is available in the Workplace back-end https://studio.cobundu.com URL for each selected location.
For example the Location ID for floor “2nd floor” in Spacewell Antwerp offices is “910000000004545”
Example 3. Reservations
To retrieve the reservations from your environment, you can use Reservations API > "get a list of bookings".
Modify dates in the search instruction and to get (filtered) reservations, each including the location ID, thus indicating which location was booked.
Enter location IDs in the search filter to get filtered data.
Example 5. Floor plan
To get a Workplace floor plan, select API Locations > "get a location's drawing as SVG"
The requested location ID in this case is the floor ID.
"Testing" in swagger will provide a response, but it cannot show the SVG.
Enter the floor location ID in following URL to see the SVG: https://go.eu1.cloud.cobundu.com/rest/v3/locations/floor location ID/drawing/svg
Example 6. Sensor Values
see REST API - GET Sensor Values
Concrete use case: URL to show live floorplan
Imagine you want to push a URL to your kiosk screens to visualize Workplace live floorplan data.
Here, we suggest to provide an access token with a URL, so that anyone with the link can see the live floorplan.
Alternative methods and Frequently Asked Questions about this can be found here: Workplace live floorplan data visualization
The below suggested dedicated method includes web authentication via Rest API. This means a Workplace login + password are needed, and the API will return a JWT token which can be used to access all other API calls. For an authorization-related action we have the COBUNDU Authorization service. It has public Swagger UI (and swagger.json-link) available at https://login.cobundu.com/rest/v2/docs. You may use the API via Swagger UI or Postman, or any other tool of your choice. This example is based on our Swagger UI.
Note
For every auth-based API method, make sure to choose the latest version (status September 2024: v2 is the latest, so refer to https://login.cobundu.com/rest/v2/docs)
Prerequisites
- Web kiosk needs to be configured in Studio
- Per floor for which you want to set up visualization, a Workplace user is needed:
Workplace minimum rights/no specific role needed
- taking into account reservation features set up for this environment
- User name + password
- To access API: Workplace user with either Admin or Developer role
Solution
-
Using API to get session token
-
Go to https://login.cobundu.com/rest/v2/docs (user needs either Admin or Developer role)
Select "auth" > /auth/ssosettings/{loginId} (return sso settings for the user)
- Provide user name
- Response body will provide the host name of COBUNDU Auth instance that needs to be used (Workplace IoT Platform is available for EU and US) (could be eg "apiUrl": https://login.eu1.cloud.cobundu.com)
-
Navigate to the apiUrl + /rest/v2/docs from previous step that is https://login.eu1.cloud.cobundu.com/rest/v2/docs is this example (user needs either Admin or Developer role)
Select "auth" > /auth/login (authenticate user)
- Specify username + password that will be used to access live data
- Change the login parameter "rememberme": true
- The rest field can be removed. Example (try not to leave a comma in the end of the password line):
- Response body will provide accessToken
- Access token is ready to be used
-
-
Prepare Web kiosk URL
Go to http://go.cobundu.com (user needs either Admin or Developer role) > Kiosk Mode
- Select the relevant floor > open web kiosk
- Web Kiosk URL will have format https://go.cobundu.com/kiosk/MEETING%7C1d18e8b0-48a7-464c-8813-66608b474d6d
- In a browser navigate to https://go.cobundu.com/rest/serverinfo or in Postman make a request to https://go.cobundu.com/rest/serverinfo?jwt= and copy/paste accessToken at the end of the URL
- The apiUrl contains a correct cloud end-point for you account (EU or US). Replace go.cobundu.com in your Web Kiosk URL with this region apiUrl, you'll obtain eg https://go.eu1.cloud.cobundu.com/kiosk/MEETING| ...
- Add suffix "?jwt=" and copy/paste accessToken at the end of the URL
-
Access this URL (for example in incognito mode), and the web kiosk will open on the chosen floor without asking for identification. A session refresh will run inside the application every 10 minutes.
After the token is obtained, there are 10 minutes to pass it in the URL to open the floor plan.
- After the floor plan is loaded, further token renewal will run automatically without session loss or any manual intervention.
Limitations
Web kiosk shows Reservation view (= combined Occupancy and Reservations data (if available))
- If browser crashes/computer is unplugged: restart the process to get a new access token
Troubleshooting
Upon error 401 with following response body, try to reload the page using F5