yazzu
yazzu

Reputation: 23

Confluence Cloud - How to update content status via the API

I'm struggling with how to find the content status of a page in Confluence.

Enter image description here

My end goal is to be able to change/update via the API.

I've added the list of statuses already in the Manage space section. I have successfully pulled the content of a page as well as its properties, but I can’t seem to find where the content status is stored.

Here is the URI I'm using:

https://MyDomain.atlassian.net/wiki/rest/api/content/145468621376?expand=space,body.storage,view,version.status,container,extentions

Upvotes: 0

Views: 1019

Answers (2)

yazzu
yazzu

Reputation: 23

Finally sorted it out with the help of Atlassian support. If their documentation was correct it would've been super easy to do this.

https://developer.atlassian.com/cloud/confluence/rest/api-group-content-states/#api-group-content-states

Heres the catch. when you GET the status you have to add on the parameter for status even though its optional. so your get string needs to look like this:

your-domain.atlassian.net/wiki/rest/api/content{id}/state?status=current

Same goes for setting the new state. You have to add on the status parameter to the uri.

Upvotes: 0

Andrii Maliuta
Andrii Maliuta

Reputation: 369

That Status is not present in OOB Confluence, so I suppose it is some third-party app from Atlassian Marketplace and you need to check with their documentation how to interact with it.

Of course, you can directly use the REST API to get page content as a string (HTML) and change its content, e.g. using Python (Atlassian Python API’s documentation) Page actions

def my_page = confluence.get_page_property(page_id, page_property_key)
def new_body = my_page.body.replace("<macro .....>", "<new status in HTML>")
confluence.update_or_create(parent_id, title, new_body, representation='storage')

Upvotes: 0

Related Questions