标签:老师 技术 history edr content metadata target data term
上篇文章介绍了Confluence提供的标准的RestAPI主要涵括在那些功能领域。在这篇文章中将会继续使用实际的例子来介绍如何使用这些RestAPI。
Confluence的相关RestAPI在上篇文章中进行了仔细的介绍,具体参看
项目 | 详细信息 |
---|---|
Confluence RestAPI介绍 | http://blog.csdn.net/liumiaocn/article/details/77814943 |
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 ~]#
[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信息
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 ~]#
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
标签:老师 技术 history edr content metadata target data term
原文地址:https://www.cnblogs.com/firsttry/p/10294094.html