Hi,
I'm trying to attach image files to an existing Confluence page from Python, using the restful API. Other requests I am making (creating or updating pages) work fine, but I keep a getting a 500 Server Error whenever sending the POST request for attaching images.
I don't see what I'm doing wrong, but I also have very little HTTP experience. Here's my little bit of code:
with open(filePath, 'rb') as fp:
# I know I am getting either .jpg or .png here, just extracting that info for the contentType
contentType = 'image/%s' % os.path.splitext(filePath)[1].replace(".", "").lower()
contentType = str(contentType.replace("jpg", "jpeg"))
files = {'file': (filePath, fp, contentType)}
headers = {'X-Atlassian-Token': 'nocheck'}
# url, user, password and pageID are all correct values
r = requests.post(url + "/%s/child/attachment" % str(pageID),
headers=headers, files=files,
auth=(user, password))
r.raise_for_status()
Solved this, the problem seemed to simply be "nocheck" instead of "no-check".
Bonus question though: is there any way to disable e-mail notifications when attaching or deleting attachements to a page?
I tried adding:
data={'version': {'minorEdit': True}}
But that doesn't seem to have an effect.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.