Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,231
Community Members
 
Community Events
165
Community Groups

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

1 accepted

1 vote
Answer accepted
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

Atlassian Access Demo Q&A Recap

Hi Community! Thank you to all who joined our ongoing monthly Atlassian Access demo! We have an engaging group of attendees who asked many great questions. I’ll share a recap of frequently ask...

1,153 views 4 4
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