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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • 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

Unable to upload an attachment on confluence page using oauth authentication, it works using basic a

 I created an application link on Confluence and  am able to get the token and secret for oauth. When I try to use the token/secret in the Atlassain Confluence python api, it doesn't work. I am able to upload an attachment using basic authentication.

Here is my code

import requests
from requests_oauthlib import OAuth1
from oauthlib.oauth1 import SIGNATURE_HMAC, SIGNATURE_RSA
from requests_oauthlib import OAuth1Session
from atlassian import Confluence

key = open("confluence_privatekey.pem").read()
print (pkeystring)
oauth = OAuth1Session('oauthkey', client_secret='oauthsecret',signature_method=SIGNATURE_RSA, rsa_key=pkeystring)

####this call is working
fetch_response = oauth.fetch_request_token('')

access_token = fetch_response.get('oauth_token')
access_token_secret = fetch_response.get('oauth_token_secret')
oauth_dict = {
'access_token': access_token,
'access_token_secret': access_token_secret,
'consumer_key': 'oauthkey',
'key_cert': pkeystring}

confluence = Confluence(url='', oauth=oauth_dict)

### this call fails but works with basic authentication
zz = confluence.attach_file("text1.txt", name='text1.txt', page_id='1234')

I get this error:

File "C:\Users\dbhatia\PycharmProjects\LearnModule\venv\lib\site-packages\atlassian\", line 522, in attach_file
File "C:\Users\dbhatia\PycharmProjects\LearnModule\venv\lib\site-packages\atlassian\", line 484, in attach_content
if attachments.get('size'):
AttributeError: 'str' object has no attribute 'get'


1 answer

0 votes
pferreira Atlassian Team Jan 13, 2020

Hi Deepika,

I would suggest reaching out to the Developer Community:

There you will be able to get better support for your development queries.



Suggest an answer

Log in or Sign up to answer
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