汇流REST API的文档可以here:
按您需要更新文件,下面的URI来执行你的要求是必要的:
/rest/api/content/{contentId}
如果你从未做过的API请求使用Python,有几个库可用,取决于你使用的是什么版本的Python。 requests,Http.client,urllib 1,2,3等等等等。
进行简单的身份验证的请求,你将最有可能需要通过融合或管理员凭据提供的令牌:
请求的例子可以发现在developers.atlassian.com 添加评论到页面:
import requests, json
def printResponse(r):
print '{} {}\n'.format(json.dumps(r.json(), sort_keys=True, indent=4, separators=(',', ': ')), r)
r = requests.get('http://localhost:8080/confluence/rest/api/content',
params={'title' : 'Page title to comment on'},
auth=('admin', 'admin'))
printResponse(r)
parentPage = r.json()['results'][0]
pageData = {'type':'comment', 'container':parentPage,
'body':{'storage':{'value':"<p>A new comment</p>",'representation':'storage'}}}
r = requests.post('http://localhost:8080/confluence/rest/api/content',
data=json.dumps(pageData),
auth=('admin','admin'),
headers=({'Content-Type':'application/json'}))
printResponse(r)
,我想孩子页面上传到已有的页面,不更新其内容的问题。另外我正在使用Python 2.7。如果我在一个步骤中创建子页面并在另一个步骤中更新它,那么您写的这个解决方案对我来说很有用。但我想一步到位。另外developers.atlassian.com链接已损坏。 –
我已更新链接,所以。你需要上传附件? – glls
不,我必须创建一个新页面,但在现有页面下。 –