Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Attaching image to Confluence page via restful API (Python) Edited

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()

 

1 answer

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

335 views 23 8
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you