Confluence REST API - expanding page body when ret

2019-07-10 02:04发布

问题:

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?

回答1:

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