SoM*_*ils 6 api rest json confluence
我想在Confluence中检索页面的所有版本.REST API中有一个声称要返回历史记录的调用,但我没有运气.
/rest/api/content/{id}/history
Run Code Online (Sandbox Code Playgroud)
当我打电话给我时,我会得到以下这样的答复:
{"latest": true,
"createdBy": {
"type": "known",
"profilePicture": {
"path": "/confluence/s/en_GB/.../profilepics/Avatar-14.png",
"width": 48,
"height": 48,
"isDefault": false
},
"username": "first.last@abc123.com",
"displayName": "First Last",
"userKey": "userKey"
}, "createdDate": "2014-12-29T13:56:16.000+0100", "_links": {
"base": "https://host.abc123.net/confluence",
"context": "/confluence",
"self": "host.abc123.net/confluence/rest/api/content/12345678/history"
}, "_expandable": {
"lastUpdated": ""
}}
Run Code Online (Sandbox Code Playgroud)
我知道这个页面通过浏览器界面在历史上有17个版本.我似乎无法通过向查询添加任何类型的expand =来获取任何内容.
Confluence REST API的文档告诉我这个调用应该:
返回内容历史记录的完整JSON表示形式
如果我转向"正常"REST API调用来检索内容,我可以获得一些关于版本结构中的历史记录的提示:
{"version": {
"by": {
"type": "known",
"profilePicture": {
"path": "/confluence/s/en_GB/5639/.../profilepics/default.png",
"width": 48,
"height": 48,
"isDefault": true
},
"username": "some.other@abc123",
"displayName": "Some Other",
"userKey": "userKeyGuidThingy"
},
"when": "2015-01-30T16:00:09.000+0100",
"message": "",
"number": 17,
"minorEdit": false
} }
Run Code Online (Sandbox Code Playgroud)
我非常热衷于检索其他版本,数字1 - 16,但我看不出如何...
我非常感谢能帮助我解开任何帮助.. :)
我找到了获取版本号的方法。
所以如果您转到https://confluence.yourdomain.com/rest/api/content/page_id(1234567)/history。您将得到以下 json 响应。
{
"previousVersion":{
"by":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"when":"date-time",
"message":"",
"number":1,
"minorEdit":false
},
"lastUpdated":{
"by":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"when":"date-time",
"message":"",
"number":2,
"minorEdit":false
},
"latest":true,
"createdBy":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"createdDate":"userkey",
"_links":{
"base":"https://confluence.yourdomain.com",
"context":"",
"self":"https://confluence.yourdomain.com/rest/api/content/page_id/history"
}
}
Run Code Online (Sandbox Code Playgroud)
从该响应 json 中获取版本号取决于您正在使用的脚本语言。对于 Python,下面的代码将获取版本号。
version=requests.get(https://confluence.yourdomain.com/rest/api/content/page_id(1234567)/history)
version= version.json()
print version['lastUpdated']['number']
Run Code Online (Sandbox Code Playgroud)
这将为您提供该页面的最新版本号。
| 归档时间: |
|
| 查看次数: |
1557 次 |
| 最近记录: |