Adaptavist Bridge
The Adaptavist bridge is a Javascript library that allows your Script Fragments to get Confluence information. The Adaptavist bridge also allows the script to use Confluence REST APIs. The bridge serves as a wrapper for the Confluence AP module and allows your scripts to communicate with Confluence.
How the Adaptavist Bridge is injected into your script is determined by what you select for your Source on the Script Fragments form:
You can choose either a Separate HTML, CSS, and Javascript URL or a Single URL for the Source.
Separate HTML, CSS, and Javascript URL source
The bridge is automatically injected, and you can call it in your script.
Single URL source
If you are hosting your own site, you must include a script tag for our bridge.js
. You can find the bridge by referencing window.AdaptavistBridge
in your Javascript. This contains a context object, which provides more information on the current environment.
The bridge is injected into the page as a global variable, which can be accessed via window.AdaptavistBridge
and window.AdaptavistBridgeContext
. The bridge can be loaded from https://assets.hydrogen.sagittarius.connect.product.adaptavist.com/public/js/bridge.js.
The AdaptavistBridge
object provides access to the request
property for making HTTP AJAX requests. The AdaptavistBridgeContext
object provides a context
property. The two properties, Request and Context, are broken down in this section.
Request property
The request
property on AdaptavistBridge
is a function. This function takes an object as an argument that includes the following properties:
url:
This property should be a relative URL to a Confluence REST API.type
: This property should be one of the following HTTP methods:GET
POST
PUT
DELETE
- Any of the other options from Confluence's AP Request options
An example of the script with the request
property:
Context property
The context
property on AdaptavistBridgeContext
is an object that can have the following possible properties:
entityKey
location
pageId
spaceId
pageVersion
contentId
contentVersion
contentType
contentPlugin
These properties allow accessing the Confluence APIs. Here is an example of what the context
object might contain:
Example
The bridge will make a request to the Confluence REST APIs with space data taken from the context object:
To receive one type of data, like the space name, use a script like this:
Here is sample code written in HTML:
Limitations
Users must have the correct permissions set in the corresponding applications to view the content displayed in the iframes.