Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence API user avatar

gorlov February 18, 2020

How can I set user avatar in confluence using it's API and python?

EDIT

Alright, I found an endpoint while using confuence in browser.

https://conf.example.ru/rest/user-profile/1.0/iserID/avatar/upload

Where can I found any docs about this endpoint? I feel like confluence has a billion different api's with like 30% documentation for each.

EDIT

I'm now trying to use this endpoint with no documentation. I'm using python requests:

requests.post('https://conf.example.ru/rest/user-profile/1.0/userID/avatar/upload', auth=HTTPBasicAuth('user', 'pass'))

And it returns 403 which means incorrect credentials, but they are correct, I copy pasted them from login page. What should I do. Documentation still needed.

1 answer

1 accepted

1 vote
Answer accepted
gorlov February 18, 2020

Alright, I've managed to do it. Turns out, that creds were correct, but I didn't provide any image data. Now It works. Just want to make clear that I figured out how to do it using f12 in browser and then, after getting the correct endpoint (which I couldn't find anywhere else), I've figured how to use it with no documentation. Thanks Obama.

harry
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 22, 2020

Hi gorlov, it is very encouraging to hear that you managed to get this endpoint to work in 2020. I have been having issues using it and would really appreciate you posting more details regarding how you accomplished this (maybe with an example). Like you said there is virtually no documentation for this endpoint anywhere and any insight you could provide would be helpful to me and other people facing this problem. 

harry
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 23, 2020
#!/usr/bin/env python3
import xmlrpc.client

server = xmlrpc.client.ServerProxy('{confluence_url}/rpc/xmlrpc'
)
token = server.confluence1.login('username', 'password')
photo_data = xmlrpc.client.Binary(open(PHOTO_PATH,'rb').read())
picture_added = server.confluence1.addProfilePicture(token, username, image_name, 'image/png', photo_data)
 

 I thought I would add an update as I found this issue very frustrating. This is a way that works with python3. picture_added is true if the profile picture for username was successfully changed. I hope this helps someone.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events