Forums

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

get_user_details_by_username don't work in Cloud using atlassian-python-api package

Zhichao Wei
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!
September 2, 2025

Hello, I try to query someone's information through get_user_details_by_username provided in confluence.py from atlassian-python-api package,which can be found in https://atlassian-python-api.readthedocs.io/confluence.html . It works well in confluence DC when url is "https://your-confluence-server.com" .
But if url is "https://your-domain.atlassian.net" which means Cloud site,it response 400.

My code is like:

detail = confluence.get_user_details_by_username('zhichaow', expand=None)

Here is detailed output after running:

2025-09-02 07:30:21,054 - atlassian.rest_client - DEBUG - curl --silent -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' 'https://internal-nvidia-uat2.atlassian.net/wiki/rest/api/user?username=zhichaow'
2025-09-02 07:30:21,117 - urllib3.connectionpool - DEBUG - https://internal-nvidia-uat2.atlassian.net:443 "GET /wiki/rest/api/user?username=zhichaow HTTP/11" 400 None
2025-09-02 07:30:21,118 - atlassian.rest_client - DEBUG - HTTP: GET rest/api/user -> 400 Bad Request
2025-09-02 07:30:21,118 - atlassian.rest_client - DEBUG - HTTP: Response text -> {"statusCode":400,"data":{"authorized":true,"valid":true,"errors":[],"successful":true},"message":"com.atlassian.confluence.api.service.exceptions.BadRequestException: Username/Userkey are not accepted as parameters."}

Could anyone help me query user details in Cloud correctly?

 

1 answer

1 accepted

0 votes
Answer accepted
ELFAPP Technologies
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 2, 2025

Hi @Zhichao Wei 

On Cloud username/userkey doesn't work. You have to use accountId if you want to retrieve a specific user. I believe that API is just for backward compatibility and doesn't reflect the actual work. Also, based on the error, it mentions that username/key are not accepted parameters.

Zhichao Wei
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!
September 2, 2025

Thanks. Do you konw why this method is deprecated in Cloud? Will the atlassian-python-api update to support retrieve user by account ID? 

Actually, I need to add @someone link in page content using python script so it depends on retrieve user by name. For example,I can add @Zhichao Wei into my page body  after using userKey = get_user_details_by_username('zhichaow') and add statement in page source:

    <ac:link>

        <ri:user ri:userkey={userKey} />

    </ac:link> 
Is there any way to solve my problem in Cloud?
Thanks.
ELFAPP Technologies
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 3, 2025

It was deprecated in favor of accountId as mentioned on this document.

I'm not sure about that if the author of the library would do that but I highly doubt they can do anything about it.

I would say typically the way userkeys were generated in the past was the prefix of an email address e.g. exampleuser@example.com, the userkey would be exampleuser maybe backward compatibility may work for now but its not guaranteed later.

However, if you're looking into identifying users, then you need to fetch the accountId beforehand to use in your Confluence tag.

You can also refer to this post as well which answers a similar question.

Zhichao Wei
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!
September 3, 2025

thanks~

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
ENTERPRISE
TAGS
AUG Leaders

Atlassian Community Events