Confluence REST: Page Metadata and Comala Workflow Status
Queries the Confluence REST search API and extends the results with Comala Workflow metadata (in this case workflow status). The example is for the case where we want to show only content created by the current user.
Datasource Type | REST Basic |
---|
Datasource URL |
CODE
<URL where Confluence is running>/rest/api
|
---|
Datasource User | An existing (functional) Confluence user (will act as bind user) |
---|
Datasource Password | Password of the (functional) Confluence user (will act as bind user) |
---|
Query URL |
CODE
content/search?cql=creator=:@username&expand=metadata.properties.comalaworkflows
|
---|
Parameter Values | Usernames of existing Confluence users (if the above wildcard is used the current user will be inserted) |
---|
Raw Result |
JSON
{
"results": [
{
"id": "24313863",
"type": "page",
"status": "current",
"title": "Comala Workflows Home",
"metadata": {
"properties": {
"_links": {
"self": "http://localhost:8090/rest/api/content/24313863/property"
}
},
"_expandable": {
"currentuser": "",
"frontend": "",
"editorHtml": "",
"labels": ""
}
},
"extensions": {
"position": "none"
},
"_links": {
"webui": "/display/CW/Comala+Workflows+Home",
"edit": "/pages/resumedraft.action?draftId=24313863",
"tinyui": "/x/BwBzAQ",
"self": "http://localhost:8090/rest/api/content/24313863"
},
"_expandable": {
"container": "/rest/api/space/CW",
"operations": "",
"children": "/rest/api/content/24313863/child",
"restrictions": "/rest/api/content/24313863/restriction/byOperation",
"history": "/rest/api/content/24313863/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/24313863/descendant",
"space": "/rest/api/space/CW"
}
},
...
}
|
---|
Converter Example |
JS
function convert(json) {
return JSON.parse(json).results.map(function(result) { // iterate through all results
var workflowState = '[ NONE ]'; // default workflow state if there is none
// Sadly, we now have to check if the state is there. It's a long chain.
if (result.metadata && result.metadata.properties && result.metadata.properties
&& result.metadata.properties.comalaworkflows && result.metadata.properties.comalaworkflows.value
&& result.metadata.properties.comalaworkflows.value.currentState) {
workflowState = result.metadata.properties.comalaworkflows.value.currentState;
}
return {
"Page ID": result.id,
"Page Title": result.title,
"Workflow State": workflowState
};
});
}
|
---|