Q. Confluence Server / Data Center を利用しています。REST API経由でページの内容を取得する場合、どのような形でリクエストすれば良いでしょうか。
関連記事: [FAQ] REST API経由で Confluence Server / Data Center のあるページの子ページの情報を取得したい
A. REST API のエンドポイント “Get Content by id” GET /rest/api/content/{id}
に対して、パラメータ "expand=body.storage" を付与してリクエストすると、ページのコンテンツ内容を含めて取得することが可能です。
Confluence 7.19.16の場合: https://docs.atlassian.com/ConfluenceServer/rest/7.19.16/#api/content-getContentById
サンプルリクエストとサンプルレスポンスは下記になります。
・サンプルリクエストURL: (基本URL)/rest/api/content/1769476?expand=body.storage ※ページIDが 1769476 の場合
・サンプルレスポンス:
{"id":"1769476","type":"page","status":"current","title":"this is title(これはページタイトルです)","body":{"storage":{"value":"<p>this is page content(これはページコンテンツです)</p>","representation":"storage","_expandable":{"content":"/rest/api/content/1769476"}},"_expandable":{"editor":"","view":"","export_view":"","styled_view":"","anonymous_export_view":""}},"extensions":{"position":"none"},"_links":{"webui":"/pages/viewpage.action?pageId=1769476","edit":"/pages/resumedraft.action?draftId=1769476&draftShareId=279eb6e9-7bcb-4ef7-9517-455f0cae80a5","tinyui":"/x/BAAb","collection":"/rest/api/content","base":"https://instenv-202992-g1kk.instenv.internal.atlassian.com","context":"","self":"(基本URL)/rest/api/content/1769476"},"_expandable":{"container":"/rest/api/space/AAA","metadata":"","operations":"","children":"/rest/api/content/1769476/child","restrictions":"/rest/api/content/1769476/restriction/byOperation","history":"/rest/api/content/1769476/history","ancestors":"","version":"","descendants":"/rest/api/content/1769476/descendant","space":"/rest/api/space/AAA"}}
※本記事は Confluence Data Center v 7.19.16 にて検証を行っています。
Ryoji Takata
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
0 comments