REST API
On this page:
The Live Input Macros provide limited capabilities to set and get macro contents using the REST API.
If you need to retrieve or update the data contained behind the Macro, you can use the following interface using any programming language of your choice.
This API is compatible with the latest version of the Live Input Macros App module.
Each Macro that is supported using the REST API has a Macro Parameter called Page Variable, which must be used if the REST API is to be utilized.
This assumes that the Page Variables, when defined on a Confluence page are all unique, no matter what type of Live Input Macro is used.
Usage
This API contains one simple endpoint, that is used to both GET and POST the data, using the Page Variable as a key.
Use the GET method prior to each batch of POST processing, as this provides the current set of Page Variables, along with all the data required to update any Page Variable.
When POST-ing updates to the same page, only allow one POST call to be active at any one time. Wait for the POST call to return before attempting another POST.
Get all Page Variables
Use this to get the current value of all the Page Variables defined on the page, it returns a JSON object containing a set of data keyed by the Page Variable names.
Returned Data Fields
“value”: holds the current value of the macro
“type”: holds the macro type, this field is needed when using the POST function
“options”: this is optional and may be empty, when present, it defines the set of choices that the macro can be set to, specifically for checkboxes, radio buttons, dropdowns and status macros.
“id”: this contains the is of the input element matching the Page Variable
GET <http://your-server>/plugins/servlet/liveinput/3/pageVariables
| Parameter | Type | Allowed values |
|---|---|---|
| pageId | string | Confluence page ID containing the Page Variable |
Response:
Either:
200: success and returned JSON data is
{
"<pageVariable-1>" : { "value" : <current-value>, "type" : <macro-type>, "options" : <valid-choices>, "id": <html-id> },
.....
"<pageVariable-n>" : { "value" : <current-value>, "type" : <macro-type>, "options" : <valid-choices>, "id": <html-id> },
}
or
500: Internal error
Set a Page Variable
Use this to set the value of a macro using the Page Variable to identify the macro. Use the GET function to obtain the current set of Page Variables on the page, along with the required parameters needed for the POST call.
POST <http://your-server>/plugins/servlet/liveinput/3/pageVariables
| Parameter | Type | Allowed values |
|---|---|---|
| pageId | string | Confluence page ID containing the Check Box macro |
| variable | string | The Page Variable defined in the macro to be updated. |
| value | string | The new value to set for the macro. This value must be one of the following, depending on the “type”, obtained from the GET call:CheckBox: one or more of the values provided in the “options” field of the GET call. When choosing multiple values, each selection must be separated by the ‘&’ character, eg. “first&second”.DatePicker: a valid date in the same format as the current value, for most cases this is d MM yy, eg. “21 JUL 2000″Cascade: not supportedDropdown: one of the values provided in the “options” field of the GET call.RadioButton: one of the values provided in the “options” field of the GET call.Status: one of the values provided in the “options” field of the GET call.Text: any string |
| type | string | The type of macro corresponding to the Page Variable, this is the “type” field provided by the GET call above. |
| string | Set this to “true” or “false” if a Page notification is required. |
Response:
200: The macro value was saved
400: An invalid parameter was provided
500: Internal server error
Authentication
In most applications, authentication will be required for the GET and POST requests, this can be done using Basic authentication or obtain a ‘personal access token’, for further details refer to Atlassian documentation on REST Authentication.