Confluence集成实践:3:RestAPI集成方式
来源:互联网 发布:贵金属行情分析软件 编辑:程序博客网 时间:2024/06/07 02:58
上篇文章介绍了Confluence提供的标准的RestAPI主要涵括在那些功能领域。在这篇文章中将会继续使用实际的例子来介绍如何使用这些RestAPI。
Rest Api
Confluence的相关RestAPI在上篇文章中进行了仔细的介绍,具体参看
创建空间
Confluence的使用,一般项目从创建一个空间开始,所以第一步,使用Space相关的Api创建一个空间。
事前确认
使用Confluence的进行确认,目前只有两个space。
利用curl,使用Confluence提供的空间查询用的API也是得到一样的结果
[root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/space 2>/dev/null |python -mjson.tool{ "_links": { "base": "http://192.168.163.134:8090", "context": "", "self": "http://192.168.163.134:8090/rest/api/space" }, "limit": 25, "results": [ { "_expandable": { "description": "", "homepage": "/rest/api/content/65547", "icon": "", "metadata": "" }, "_links": { "self": "http://192.168.163.134:8090/rest/api/space/ds", "webui": "/display/ds" }, "id": 98305, "key": "ds", "name": "Demonstration Space", "type": "global" }, { "_expandable": { "description": "", "homepage": "/rest/api/content/65580", "icon": "", "metadata": "" }, "_links": { "self": "http://192.168.163.134:8090/rest/api/space/SAM", "webui": "/display/SAM" }, "id": 98306, "key": "SAM", "name": "SampleSpace", "type": "global" } ], "size": 2, "start": 0}[root@ku8-4 ~]#
name:相关的项目记载着空间名称,可以看出目前只有两个,和图形界面取得的结果是一致的。
[root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/space 2>/dev/null |python -mjson.tool |grep name "name": "Demonstration Space", "name": "SampleSpace",[root@ku8-4 ~]#
创建空间
API
curl -u admin1:admin123 -X POST -H ‘Content-Type: application/json’ -d’ {“key”: “TST”, “name”: “Example space”, “description”: { “plain”: { “value”: “This is an example space”, “representation”: “plain” } }, “metadata”: {}} ’ http://192.168.163.134:8090/rest/api/space
执行日志
[root@ku8-4 ~]# curl -u admin1:admin123 -X POST -H 'Content-Type: application/json' -d' {"key": "TST", "name": "Example space", "description": { "plain": { "value": "This is an example space", "representation": "plain" } }, "metadata": {}} ' http://192.168.163.134:8090/rest/api/space{"id":98309,"key":"TST","name":"Example space","description":{"plain":{"value":"This is an example space","representation":"plain"},"_expandable":{"view":""}},"homepage":{"id":"65617","type":"page","status":"current","title":"Example space Home","extensions":{"position":"none"},"_links":{"webui":"/display/TST/Example+space+Home","edit":"/pages/resumedraft.action?draftId=65617","tinyui":"/x/UQAB","self":"http://192.168.163.134:8090/rest/api/content/65617"},"_expandable":{"container":"/rest/api/space/TST","metadata":"","operations":"","children":"/rest/api/content/65617/child","history":"/rest/api/content/65617/history","ancestors":"","body":"","version":"","descendants":"/rest/api/content/65617/descendant","space":"/rest/api/space/TST"}},"type":"global","_links":{"webui":"/display/TST","collection":"/rest/api/space","base":"http://192.168.163.134:8090","context":"","self":"http://192.168.163.134:8090/rest/api/space/TST"},"_expandable":{"metadata":"","icon":""}}[root@ku8-4 ~]#
创建后确认
[root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/space 2>/dev/null |python -mjson.tool{ "_links": { "base": "http://192.168.163.134:8090", "context": "", "self": "http://192.168.163.134:8090/rest/api/space" }, "limit": 25, "results": [ { "_expandable": { "description": "", "homepage": "/rest/api/content/65547", "icon": "", "metadata": "" }, "_links": { "self": "http://192.168.163.134:8090/rest/api/space/ds", "webui": "/display/ds" }, "id": 98305, "key": "ds", "name": "Demonstration Space", "type": "global" }, { "_expandable": { "description": "", "homepage": "/rest/api/content/65617", "icon": "", "metadata": "" }, "_links": { "self": "http://192.168.163.134:8090/rest/api/space/TST", "webui": "/display/TST" }, "id": 98309, "key": "TST", "name": "Example space", "type": "global" }, { "_expandable": { "description": "", "homepage": "/rest/api/content/65580", "icon": "", "metadata": "" }, "_links": { "self": "http://192.168.163.134:8090/rest/api/space/SAM", "webui": "/display/SAM" }, "id": 98306, "key": "SAM", "name": "SampleSpace", "type": "global" } ], "size": 3, "start": 0}[root@ku8-4 ~]# [root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/space 2>/dev/null |python -mjson.tool |grep name "name": "Demonstration Space", "name": "Example space", "name": "SampleSpace",[root@ku8-4 ~]#
页面确认
确认group信息
[root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/group 2>/dev/null |python -mjson.tool{ "_links": { "base": "http://192.168.163.134:8090", "context": "", "self": "http://192.168.163.134:8090/rest/api/group" }, "limit": 200, "results": [ { "_links": { "self": "http://192.168.163.134:8090/rest/experimental/group/confluence-administrators" }, "name": "confluence-administrators", "type": "group" }, { "_links": { "self": "http://192.168.163.134:8090/rest/experimental/group/confluence-users" }, "name": "confluence-users", "type": "group" } ], "size": 2, "start": 0}[root@ku8-4 ~]#
确认用户信息
[root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/user?username=admin 2>/dev/null |python -mjson.tool{ "_links": { "base": "http://192.168.163.134:8090", "context": "", "self": "http://192.168.163.134:8090/rest/experimental/user?key=402823065e3f8d2b015e3f9595f20000" }, "displayName": "admin", "profilePicture": { "height": 48, "isDefault": true, "path": "/images/icons/profilepics/default.png", "width": 48 }, "type": "known", "userKey": "402823065e3f8d2b015e3f9595f20000", "username": "admin"}[root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/user?username=admin1 2>/dev/null |python -mjson.tool{ "_links": { "base": "http://192.168.163.134:8090", "context": "", "self": "http://192.168.163.134:8090/rest/experimental/user?key=402823065e3f8d2b015e3fa2472d0001" }, "displayName": "administrator", "profilePicture": { "height": 48, "isDefault": false, "path": "/download/attachments/65575/user-avatar", "width": 48 }, "type": "known", "userKey": "402823065e3f8d2b015e3fa2472d0001", "username": "admin1"}[root@ku8-4 ~]#
创建content
事前确认
确认目前的content信息
curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/content/ 2>/dev/null| python -mjson.tool
[root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/content/ 2>/dev/null| python -mjson.tool{ "_links": { "base": "http://192.168.163.134:8090", "context": "", "self": "http://192.168.163.134:8090/rest/api/content/" }, "limit": 25, "results": [ { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65537/child", "container": "/rest/api/space/ds", "descendants": "/rest/api/content/65537/descendant", "history": "/rest/api/content/65537/history", "metadata": "", "operations": "", "space": "/rest/api/space/ds", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65537", "self": "http://192.168.163.134:8090/rest/api/content/65537", "tinyui": "/x/AQAB", "webui": "/pages/viewpage.action?pageId=65537" }, "extensions": { "position": 8 }, "id": "65537", "status": "current", "title": "Share your page with a team member (step 9 of 9)", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65539/child", "container": "/rest/api/space/ds", "descendants": "/rest/api/content/65539/descendant", "history": "/rest/api/content/65539/history", "metadata": "", "operations": "", "space": "/rest/api/space/ds", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65539", "self": "http://192.168.163.134:8090/rest/api/content/65539", "tinyui": "/x/AwAB", "webui": "/pages/viewpage.action?pageId=65539" }, "extensions": { "position": 4 }, "id": "65539", "status": "current", "title": "Get serious with a table (step 5 of 9)", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65540/child", "container": "/rest/api/space/ds", "descendants": "/rest/api/content/65540/descendant", "history": "/rest/api/content/65540/history", "metadata": "", "operations": "", "space": "/rest/api/space/ds", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65540", "self": "http://192.168.163.134:8090/rest/api/content/65540", "tinyui": "/x/BAAB", "webui": "/pages/viewpage.action?pageId=65540" }, "extensions": { "position": 7 }, "id": "65540", "status": "current", "title": "Tell people what you think in a comment (step 8 of 9)", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65541/child", "container": "/rest/api/space/ds", "descendants": "/rest/api/content/65541/descendant", "history": "/rest/api/content/65541/history", "metadata": "", "operations": "", "space": "/rest/api/space/ds", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65541", "self": "http://192.168.163.134:8090/rest/api/content/65541", "tinyui": "/x/BQAB", "webui": "/pages/viewpage.action?pageId=65541" }, "extensions": { "position": 3 }, "id": "65541", "status": "current", "title": "Prettify the page with an image (step 4 of 9)", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65543/child", "container": "/rest/api/space/ds", "descendants": "/rest/api/content/65543/descendant", "history": "/rest/api/content/65543/history", "metadata": "", "operations": "", "space": "/rest/api/space/ds", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65543", "self": "http://192.168.163.134:8090/rest/api/content/65543", "tinyui": "/x/BwAB", "webui": "/pages/viewpage.action?pageId=65543" }, "extensions": { "position": 5 }, "id": "65543", "status": "current", "title": "Lay out your page (step 6 of 9)", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65544/child", "container": "/rest/api/space/ds", "descendants": "/rest/api/content/65544/descendant", "history": "/rest/api/content/65544/history", "metadata": "", "operations": "", "space": "/rest/api/space/ds", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65544", "self": "http://192.168.163.134:8090/rest/api/content/65544", "tinyui": "/x/CAAB", "webui": "/pages/viewpage.action?pageId=65544" }, "extensions": { "position": 2 }, "id": "65544", "status": "current", "title": "Let's edit this page (step 3 of 9)", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65545/child", "container": "/rest/api/space/ds", "descendants": "/rest/api/content/65545/descendant", "history": "/rest/api/content/65545/history", "metadata": "", "operations": "", "space": "/rest/api/space/ds", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65545", "self": "http://192.168.163.134:8090/rest/api/content/65545", "tinyui": "/x/CQAB", "webui": "/pages/viewpage.action?pageId=65545" }, "extensions": { "position": 1 }, "id": "65545", "status": "current", "title": "A quick look at the editor (step 2 of 9)", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65546/child", "container": "/rest/api/space/ds", "descendants": "/rest/api/content/65546/descendant", "history": "/rest/api/content/65546/history", "metadata": "", "operations": "", "space": "/rest/api/space/ds", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65546", "self": "http://192.168.163.134:8090/rest/api/content/65546", "tinyui": "/x/CgAB", "webui": "/pages/viewpage.action?pageId=65546" }, "extensions": { "position": 0 }, "id": "65546", "status": "current", "title": "What is Confluence? (step 1 of 9)", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65547/child", "container": "/rest/api/space/ds", "descendants": "/rest/api/content/65547/descendant", "history": "/rest/api/content/65547/history", "metadata": "", "operations": "", "space": "/rest/api/space/ds", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65547", "self": "http://192.168.163.134:8090/rest/api/content/65547", "tinyui": "/x/CwAB", "webui": "/display/ds/Welcome+to+Confluence" }, "extensions": { "position": 8 }, "id": "65547", "status": "current", "title": "Welcome to Confluence", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65548/child", "container": "/rest/api/space/ds", "descendants": "/rest/api/content/65548/descendant", "history": "/rest/api/content/65548/history", "metadata": "", "operations": "", "space": "/rest/api/space/ds", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65548", "self": "http://192.168.163.134:8090/rest/api/content/65548", "tinyui": "/x/DAAB", "webui": "/pages/viewpage.action?pageId=65548" }, "extensions": { "position": 6 }, "id": "65548", "status": "current", "title": "Learn the wonders of autoconvert (step 7 of 9)", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65580/child", "container": "/rest/api/space/SAM", "descendants": "/rest/api/content/65580/descendant", "history": "/rest/api/content/65580/history", "metadata": "", "operations": "", "space": "/rest/api/space/SAM", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65580", "self": "http://192.168.163.134:8090/rest/api/content/65580", "tinyui": "/x/LAAB", "webui": "/display/SAM/SampleSpace" }, "extensions": { "position": "none" }, "id": "65580", "status": "current", "title": "SampleSpace", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65596/child", "container": "/rest/api/space/SAM", "descendants": "/rest/api/content/65596/descendant", "history": "/rest/api/content/65596/history", "metadata": "", "operations": "", "space": "/rest/api/space/SAM", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65596&draftShareId=fb9fac91-4805-4f25-8fed-7f41c7182ca2", "self": "http://192.168.163.134:8090/rest/api/content/65596", "tinyui": "/x/PAAB", "webui": "/pages/viewpage.action?pageId=65596" }, "extensions": { "position": "none" }, "id": "65596", "status": "current", "title": "2017-09-02 \u4f1a\u8bae\u7eaa\u8981", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65603/child", "container": "/rest/api/space/SAM", "descendants": "/rest/api/content/65603/descendant", "history": "/rest/api/content/65603/history", "metadata": "", "operations": "", "space": "/rest/api/space/SAM", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65603", "self": "http://192.168.163.134:8090/rest/api/content/65603", "tinyui": "/x/QwAB", "webui": "/pages/viewpage.action?pageId=65603" }, "extensions": { "position": "none" }, "id": "65603", "status": "current", "title": "\u6587\u4ef6\u5217\u8868", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65604/child", "container": "/rest/api/space/SAM", "descendants": "/rest/api/content/65604/descendant", "history": "/rest/api/content/65604/history", "metadata": "", "operations": "", "space": "/rest/api/space/SAM", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65604", "self": "http://192.168.163.134:8090/rest/api/content/65604", "tinyui": "/x/RAAB", "webui": "/pages/viewpage.action?pageId=65604" }, "extensions": { "position": "none" }, "id": "65604", "status": "current", "title": "\u5f00\u53d1\u6587\u6863", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65608/child", "container": "/rest/api/space/SAM", "descendants": "/rest/api/content/65608/descendant", "history": "/rest/api/content/65608/history", "metadata": "", "operations": "", "space": "/rest/api/space/SAM", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65608", "self": "http://192.168.163.134:8090/rest/api/content/65608", "tinyui": "/x/SAAB", "webui": "/pages/viewpage.action?pageId=65608" }, "extensions": { "position": "none" }, "id": "65608", "status": "current", "title": "\u6d4b\u8bd5\u6587\u6863", "type": "page" }, { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/65617/child", "container": "/rest/api/space/TST", "descendants": "/rest/api/content/65617/descendant", "history": "/rest/api/content/65617/history", "metadata": "", "operations": "", "space": "/rest/api/space/TST", "version": "" }, "_links": { "edit": "/pages/resumedraft.action?draftId=65617", "self": "http://192.168.163.134:8090/rest/api/content/65617", "tinyui": "/x/UQAB", "webui": "/display/TST/Example+space+Home" }, "extensions": { "position": "none" }, "id": "65617", "status": "current", "title": "Example space Home", "type": "page" } ], "size": 16, "start": 0}[root@ku8-4 ~]#
创建
以title为”new page”创建一个content,创建前后确认,确认创建的RESTAPI能够正常动作。
curl -u admin1:admin123 -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"new page","space":{"key":"TST"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' http://192.168.163.134:8090/rest/api/content/ 2>/dev/null| python -mjson.tool
[root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/content/ 2>/dev/null| python -mjson.tool |grep 'new page'[root@ku8-4 ~]# curl -u admin1:admin123 -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"new page","space":{"key":"TST"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' http://192.168.163.134:8090/rest/api/content/ 2>/dev/null| python -mjson.tool{ "_expandable": { "children": "/rest/api/content/65618/child", "descendants": "/rest/api/content/65618/descendant", "metadata": "", "operations": "" }, "_links": { "base": "http://192.168.163.134:8090", "collection": "/rest/api/content", "context": "", "edit": "/pages/resumedraft.action?draftId=65618", "self": "http://192.168.163.134:8090/rest/api/content/65618", "tinyui": "/x/UgAB", "webui": "/display/TST/new+page" }, "ancestors": [], "body": { "_expandable": { "anonymous_export_view": "", "editor": "", "export_view": "", "styled_view": "", "view": "" }, "storage": { "_expandable": { "content": "/rest/api/content/65618" }, "representation": "storage", "value": "<p>This is a new page</p>" } }, "container": { "_expandable": { "description": "", "homepage": "/rest/api/content/65617", "icon": "", "metadata": "" }, "_links": { "self": "http://192.168.163.134:8090/rest/api/space/TST", "webui": "/display/TST" }, "id": 98309, "key": "TST", "name": "Example space", "type": "global" }, "extensions": { "position": "none" }, "history": { "_expandable": { "contributors": "", "lastUpdated": "", "nextVersion": "", "previousVersion": "" }, "_links": { "self": "http://192.168.163.134:8090/rest/api/content/65618/history" }, "createdBy": { "_links": { "self": "http://192.168.163.134:8090/rest/experimental/user?key=402823065e3f8d2b015e3fa2472d0001" }, "displayName": "administrator", "profilePicture": { "height": 48, "isDefault": false, "path": "/download/attachments/65575/user-avatar", "width": 48 }, "type": "known", "userKey": "402823065e3f8d2b015e3fa2472d0001", "username": "admin1" }, "createdDate": "2017-09-03T02:06:48.035-04:00", "latest": true }, "id": "65618", "space": { "_expandable": { "description": "", "homepage": "/rest/api/content/65617", "icon": "", "metadata": "" }, "_links": { "self": "http://192.168.163.134:8090/rest/api/space/TST", "webui": "/display/TST" }, "id": 98309, "key": "TST", "name": "Example space", "type": "global" }, "status": "current", "title": "new page", "type": "page", "version": { "_expandable": { "content": "/rest/api/content/65618" }, "_links": { "self": "http://192.168.163.134:8090/rest/experimental/content/65618/version/1" }, "by": { "_links": { "self": "http://192.168.163.134:8090/rest/experimental/user?key=402823065e3f8d2b015e3fa2472d0001" }, "displayName": "administrator", "profilePicture": { "height": 48, "isDefault": false, "path": "/download/attachments/65575/user-avatar", "width": 48 }, "type": "known", "userKey": "402823065e3f8d2b015e3fa2472d0001", "username": "admin1" }, "hidden": false, "message": "", "minorEdit": false, "number": 1, "when": "2017-09-03T02:06:48.035-04:00" }}[root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/content/ 2>/dev/null| python -mjson.tool |grep 'new page' "title": "new page",[root@ku8-4 ~]#
Confluence确认
从Confluence里也可以清楚地确认到是添加了一个new page的content
确认具体内容
附件管理
事前确认
新建的content下没有任何附件
[root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/content/65618/child/attachment 2>/dev/null |python -mjson.tool{ "_links": { "base": "http://192.168.163.134:8090", "context": "", "self": "http://192.168.163.134:8090/rest/api/content/65618/child/attachment" }, "limit": 50, "results": [], "size": 0, "start": 0}[root@ku8-4 ~]#
创建附件
[root@ku8-4 ~]# cat myfile.txt My Test File Info [root@ku8-4 ~]# curl -D- -u admin1:admin123 -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.txt" -F "comment=This is my File" http://192.168.163.134:8090/rest/api/content/65618/child/attachmentHTTP/1.1 100 ContinueHTTP/1.1 200 OKServer: Apache-Coyote/1.1X-ASEN: SEN-L10256677Set-Cookie: JSESSIONID=D7EA9239BF035C0F267C20A948CCBC06; Path=/; HttpOnlyX-Seraph-LoginReason: OKX-AUSERNAME: admin1Cache-Control: no-cache, must-revalidateExpires: Thu, 01 Jan 1970 00:00:00 GMTX-Content-Type-Options: nosniffContent-Type: application/jsonTransfer-Encoding: chunkedDate: Sun, 03 Sep 2017 06:27:57 GMT{"results":[{"id":"att65622","type":"attachment","status":"current","title":"myfile.txt","version":{"by":{"type":"known","username":"admin1","userKey":"402823065e3f8d2b015e3fa2472d0001","profilePicture":{"path":"/download/attachments/65575/user-avatar","width":48,"height":48,"isDefault":false},"displayName":"administrator","_links":{"self":"http://192.168.163.134:8090/rest/experimental/user?key=402823065e3f8d2b015e3fa2472d0001"}},"when":"2017-09-03T02:27:56.763-04:00","message":"This is my File","number":1,"minorEdit":false,"hidden":false,"_links":{"self":"http://192.168.163.134:8090/rest/experimental/content/att65622/version/1"},"_expandable":{"content":"/rest/api/content/att65622"}},"container":{"id":"65618","type":"page","status":"current","title":"new page","extensions":{"position":"none"},"_links":{"webui":"/display/TST/new+page","edit":"/pages/resumedraft.action?draftId=65618","tinyui":"/x/UgAB","self":"http://192.168.163.134:8090/rest/api/content/65618"},"_expandable":{"container":"/rest/api/space/TST","metadata":"","operations":"","children":"/rest/api/content/65618/child","history":"/rest/api/content/65618/history","ancestors":"","body":"","version":"","descendants":"/rest/api/content/65618/descendant","space":"/rest/api/space/TST"}},"metadata":{"comment":"This is my File","mediaType":"text/plain","_expandable":{"currentuser":"","properties":"","frontend":""}},"extensions":{"mediaType":"text/plain","fileSize":19,"comment":"This is my File"},"_links":{"webui":"/display/TST/new+page?preview=%2F65618%2F65622%2Fmyfile.txt","download":"/download/attachments/65618/myfile.txt?version=1&modificationDate=1504420076763&api=v2","self":"http://192.168.163.134:8090/rest/api/content/att65622"},"_expandable":{"operations":"","children":"/rest/api/content/att65622/child","history":"/rest/api/content/att65622/history","ancestors":"","body":"","descendants":"/rest/api/content/att65622/descendant","space":"/rest/api/space/TST"}}],"size":1,"_links":{"base":"http://192.168.163.134:8090","context":""}}[root@ku8-4 ~]# [root@ku8-4 ~]#
创建后确认
使用api方式确认
[root@ku8-4 ~]# curl -u admin1:admin123 http://192.168.163.134:8090/rest/api/content/65618/child/attachment 2>/dev/null |python -mjson.tool{ "_links": { "base": "http://192.168.163.134:8090", "context": "", "self": "http://192.168.163.134:8090/rest/api/content/65618/child/attachment" }, "limit": 50, "results": [ { "_expandable": { "ancestors": "", "body": "", "children": "/rest/api/content/att65622/child", "container": "/rest/api/content/65618", "descendants": "/rest/api/content/att65622/descendant", "history": "/rest/api/content/att65622/history", "operations": "", "space": "/rest/api/space/TST", "version": "" }, "_links": { "download": "/download/attachments/65618/myfile.txt?version=1&modificationDate=1504420076763&api=v2", "self": "http://192.168.163.134:8090/rest/api/content/att65622", "webui": "/display/TST/new+page?preview=%2F65618%2F65622%2Fmyfile.txt" }, "extensions": { "comment": "This is my File", "fileSize": 19, "mediaType": "text/plain" }, "id": "att65622", "metadata": { "_expandable": { "currentuser": "", "frontend": "", "properties": "" }, "comment": "This is my File", "labels": { "_links": { "self": "http://192.168.163.134:8090/rest/api/content/att65622/label" }, "limit": 200, "results": [], "size": 0, "start": 0 }, "mediaType": "text/plain" }, "status": "current", "title": "myfile.txt", "type": "attachment" } ], "size": 1, "start": 0}[root@ku8-4 ~]#
从页面确认
文件内容确认
注意要点
RestAPI方式访问,注意以下小问题
1. 官方文件提供的访问方式均类似为/rest/space格式,但是根据情况方式略有不同,不然会出现FILE NOT FOUND的低级问题,比如例子中均为/rest/api方式
2. 另外官方文档提供的是需要confluence的context的方式,所以/confluence一般也不需要,注意官方文档是举例,不是拿来直接使用
3. 建议实际生产环境中,提前验证一下,以防止安装设定不同带来影响
总结
RestAPI方式可以与Confluence进行集成,但是功能还略显不足,提供了关键的space和content的CRUD以及附件的管理方式,但是很多Confluence的强大功能还不能全部通过API来进行集成,事前无比确认此点。
参考文献
https://docs.atlassian.com/atlassian-confluence/REST/latest-server/#space-createSpace
https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples
- Confluence集成实践:3:RestAPI集成方式
- Confluence集成实践:2:Confluence的RestAPI
- Redmine之RestApi集成方式
- Confluence集成实践:1:安装
- 集成confluence与jira
- JIRA与Confluence破解集成全过程
- Confluence+Crowd的集成(openLDAP认证)
- 安装配置Jira和Confluence集成环境
- jira+Confluence+FishEye安装破解集成
- JIRA confluence 集成crowd单点登录
- Spring Boot实践-3(集成freemarker)
- JMX 集成动手实践
- 持续集成: 实践指南
- 持续集成最佳实践
- 持续集成实践
- Spring集成Restlet实践
- PHP持续集成实践
- 集成学习实践(sklearn)
- ZooKeeper_9_Java操作ZK_检测节点
- ZooKeeper之以复制模式(replicated mode)运行(Windows环境)(二)
- 怎么把java代码转到jsp页面中
- C++Primer第五版 1.5.1节练习
- 设计模式之命令模式
- Confluence集成实践:3:RestAPI集成方式
- Java常用工具类封装——String操作工具类
- 总结Java中的next()和nextLine()方法的区别
- UNIX环境编程学习笔记(13)——文件I/O之标准I/O流
- RobotFramwork(一)安装篇
- bam文件softclip , hardclip ,markduplicate的探究
- fabirc1.0商业正式版本源码解析11---peer的Admin和Endorser服务
- 常用SQL查询语句
- AtCoder Beginner Contest 072 ABCD C++&&Python3