0

Is it possible to get the whole content of a Confluence Space from REST Api?

I try this example curl -u admin:admin http://localhost:8080/confluence/rest/api/content/3965072?expand=body.storage

But this is only the first page content.

user3498116
  • 31
  • 1
  • 5
  • For the sake of others, only one page is returned because that is specifically what's asked for via the RestAPI, content of page 3965072. – ScottWelker May 29 '18 at 23:17
  • Note too that knowing your specific Confluence RestAPI version is important. Although, I suspect the later version(s) are more alike then say 3.x version(s). – ScottWelker May 29 '18 at 23:32

2 Answers2

1

In the Confluence RestAPIs with which I worked it was important to recognize that every page is conceptually similar to a Space in that it may also contain other pages. There are also collections of things, like attachments, that hang off of the pages. As I recall the process is roughly this:

  • Get the collection of spaces.
  • Iterate the collection of spaces until there are no more.
    • For each space get its collection of page(s); "root pages" come to mind.
      • Iterate/recurse the root-page collection retrieving all page content and/or "attached things" you want.
        • Recursion is the key here.

Note my earlier comment about making sure you reference the correct Confluence RestAPI documentation for your specific version. That was a point of GREAT confusion for me.

ScottWelker
  • 1,701
  • 17
  • 30
0

Yes, to need to do something like this:

http://localhost:8080/confluence/rest/api/space/SPACE_KEY/content?expand=body.storage

You can get also a specific type of content item (page or blogpost) like this:

http://localhost:8080/confluence/rest/api/space/SPACE_KEY/content/page?expand=body.storage

http://localhost:8080/confluence/rest/api/space/SPACE_KEY/content/blogpost?expand=body.storage

You need to take in consideration the pagination: https://developer.atlassian.com/confdev/confluence-rest-api/pagination-in-the-rest-api

mtheriault
  • 1,065
  • 9
  • 21