3

I'm accessing a Confluence page by its title using the latest REST API. To retrieve more details on certain fields, I'm passing the expand parameter (see Confluence Docs):

https://xyz.atlassian.net/wiki/rest/api/content/?title=Architecture&spaceKey=XX&expand=body

or

https://xyz.atlassian.net/wiki/rest/api/content/?title=Architecture&spaceKey=XX&expand=body.view

But the results don't hold any information on the found page body.

Note, this is working fine with requests using a page id only. Using the title to retrieve the page is threaded similar to search results, hence the expand feature seems not to work the same. According to the documentation it should work as per my example. Am I missing something?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
david
  • 2,529
  • 1
  • 34
  • 50
  • How about two requests: The first using title to find the ID and then the second to request by ID with the body expansion? – Adam Taylor Dec 18 '15 at 11:26
  • Thanks Adam, that's the current solution, but performance-wise it's not acceptable. – david Dec 21 '15 at 14:43

1 Answers1

4

You need to specify which type of "body" you want in the expansion parameter.

In your case, something like this:

https://xyz.atlassian.net/wiki/rest/api/content/?title=Architecture&spaceKey=XX&expand=body.view

https://xyz.atlassian.net/wiki/rest/api/content/?title=Architecture&spaceKey=XX&expand=body.export_view

Possible values are:

  • editor
  • export_view
  • anonymous_export_view
  • view
  • storage
mtheriault
  • 1,065
  • 9
  • 21
  • 1
    Thanks for your answer! Indeed I tried a combination of various parameters, such as: `&spaceKey=XX&type=page&expand=space,body.view,version,container,page.body.view,results.body.view,page.body,results.body` - but the results always stays the same – david Dec 21 '15 at 14:42
  • Mmm... very strange, it works on my instances (v5.7 et v5.8.5): .../rest/api/content?spaceKey=DOC&title=Making%20a%20template&expand=body.export_view – mtheriault Dec 21 '15 at 14:57
  • Do you have a self-hosted instance or Confluence on demand (cloud hosted)? On the PAAS instances Atlassian has some different settings... – david Dec 21 '15 at 15:26
  • Yes, I have just tried it and it seems that the "title" query parameter doesn't work. I can do this: /wiki/rest/api/content?spaceKey=DS1&expand=body.view, but not this: /wiki/rest/api/content?spaceKey=DS1&title="Demonstration%20Space"&expand=export.view. No results are returned like you. Seems to be a bug in the version 6. – mtheriault Dec 21 '15 at 15:56
  • 1
    You may try the Search REST API and CQL, it seems to work in my case: **/wiki/rest/api/content/search?cql=space="DS1"%20and%20title="My%20First%20Page"&expand=body.view** – mtheriault Dec 21 '15 at 16:05
  • +1 for the `export_view`. This helped me to copy a page containing macros. I had a requirement to copy not the macros but the macro's result. `export_view` helped to achieve that. Is there a better way or that's the right way? – Sandeep Kanabar Jan 14 '17 at 17:58