我如何在使用带oauth1和python的Confluence api时发布附件?

问题描述 投票:0回答:1

我可以使用oauth1成功更新调用confluence api的confluence页面。但是我无法发布附件。我看过多个博客,但找不到任何解决方案。

python attachment confluence oauth-1.0a
1个回答
0
投票

我能够使用pythons库“ requests_oauthlib”解决此问题。下面是我用于在汇合时更新附件的代码片段。

def send_attachment(self, pageid, attachmentid):
        headers = {"X-Atlassian-Token": "nocheck"}
        oauth = OAuth1(self.client_key, client_secret=self.client_secret,
                       resource_owner_key=self.resource_owner_key,
                       resource_owner_secret=self.resource_owner_secret,
                       signature_type='auth_header', rsa_key=self.key, signature_method='RSA-SHA1')
        r = requests.post(url="https://cps.confluence.abc.com/rest/api/content/" + pageid + "/child/attachment/" + attachmentid + "/data", auth=oauth, files=self.files, headers=headers)
        print(r.status_code)
© www.soinside.com 2019 - 2024. All rights reserved.