API to script changes to pages?


We would like to migrate our on-premises Confluence to Confluence Cloud however we have used a custom user NoPrint macro throughout most of our pages. Unfortunately user macros are not supported in the Cloud. We don't mind removing the macro but we have thousands of pages so manually updating the content is not a viable option.

Can I migrate the content to the Cloud and then update our pages via an API or some other kind of scripting?

Any suggestions would be greatly appreciated.



2 answers

0 votes


The Confluence REST api has what i think you need, I would approach it like this:

1) Use CQL to find all pages with your macro on it (See: https://developer.atlassian.com/confdev/confluence-rest-api/advanced-searching-using-cql#AdvancedSearchingusingCQL-macroMacroMacro).  I just had a thought, this may not work with a macro that is no longer installed.  If it doesn't, you can just parse all pages.

2) For each file, you can parse the structured storage format using the content api (See: https://developer.atlassian.com/confdev/confluence-rest-api/confluence-rest-api-examples)

3) The storage format is well structured XHTML so you can use jquery or some other library to parse and manipulate it.

Good luck!



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in New to Confluence

How to use Confluence Cloud for stakeholder management

Most of us don’t need much convincing that stakeholder management is important. It just makes sense that keeping everyone in-the-know on projects and assigning clearly defined roles is key to having ...

1,120 views 2 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you