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

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

Get accountId after updating account using PUT

I am calling PUT API to update a user account. The updated account has different username and primary email than the account on creation. In the response of the API, I am getting urn:scim:schemas:extension:atlassian-external:1.0 : [], that is no external accountId is getting fetched in the response. 

To call APIs listed in ConfluenceCloud REST APIs, I need accountId to be passed as the request parameter (like in Add space permissions for user API).

I have come across find users api where I can pass primary email of user in request parameter and get the accountId of that account in response. However, I can get accountId only if the email of the account has not been not updated since account creation. 

Is there any API to get accountId even if account's primary email has been updated? Without the accountId I cannot add space permissions for a user in Confluence cloud.

1 answer

0 votes
Dario B Atlassian Team Jul 23, 2021

Hello @Mrinalini Pal ,

In order to get the accountID for a user via REST API there are multiple options:

1) Use the Search users REST API endpoint for Confluence and search for a string that matches the public name or display name or the email address of the user like in below example:

https://XXXXX.atlassian.net/wiki/rest/api/search/user?cql=user=dario

{
"results": [
{
"user": {
"type": "known",
"accountId": "557XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXc",
"accountType": "",
"email": "dbXXXXXXX@atlassian.com",
"publicName": "Dario B",
"profilePicture": {
"path": "/wiki/aa-avatar/557XXXXXXXXXXXXXXXXc",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "Dario BXXXXXXXX",

 

 2) Use the Jira REST API endpoint you already found but match the displayName instead of the email address if this is not working for you:

https://XXXXXXX.atlassian.net/rest/api/3/user/search?query=dario

[
{
"self": "https://xxxxxx.atlassian.net/rest/api/3/user?accountId=5570xxxxxxxxxxxxxxxxxxxxxc",
"accountId": "557xxxxxxxxxxxxxxxxxxxxxxxxxxc",
"accountType": "atlassian",
"emailAddress": "dbxxxxxxxxx@atlassian.com",
"avatarUrls": {
[... removed ...]
},
"displayName": "Dario BXXXXXXX",

 

3) I am not sure about this since I have never tried myself, so please double-check, but the externalID that you get when using the User Provisioning REST API should match the accountID and therefore you could use one of the below endpoints: 

 

 

Finally, I'd like to get more details on the fact that you are not able to use the find users api if the email address has changed since I am not aware of this issue.

Have you actually checked if it is not just a matter of time after changing the email address (you might have to wait for it to be synchronized), or you are not able to search for email addresses that have been updated in the past days too?

Please let me know.

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Atlassian Access

Resources + Q&A from "What's new in Atlassian Access" webinar

Hi Community! Thank you to all those who joined our What’s new in Atlassian Access webinar last week! We received so many great questions about existing functionality and newly released features of...

933 views 0 7
Read article

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