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

Update user account with email unchanged using User Provisioning REST API

Mrinalini Pal July 19, 2021

I am trying to update a user account using User Provisioning REST API mentioned in the https://developer.atlassian.com/cloud/admin/user-provisioning/rest/api-group-users/#api-scim-directory-directoryid-users-userid-put  document.

  • If no primary email is sent as the request body, I am getting "Invalid payload: One email address need to be marked as primary." error.
  • If primary email is unchanged in the request body, I am getting success but the user details are not getting updated.
  • If primary email is changed in the request body, I am getting success and the user details are getting updated. 

I want to change the email of the user only when the user requests for a change otherwise I want the details to get updated having the same email. Is there any work-around or is this a bug?

2 answers

1 accepted

0 votes
Answer accepted
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 20, 2021

Hello Mrinalini,

Welcome to Atlassian Community! It's nice to have you join us. 

Can you show us the query you're sending in REST-API? Please make sure to block out any private information since this is a public forum.

You might also want to try the Atlassian Developer Community. The main community is more end users, but the Developer community works with API regularly and may know what the problem is.

Thank you!
Shannon

Mrinalini Pal July 20, 2021

Hi Shannon,

I am calling the following API :
curl --request PUT \
--url 'https://api.atlassian.com/scim/directory/{directoryId}/Users/{userId}' \
--header 'Authorization: Bearer <access_token>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"userName": "<string>",
"emails": [
{
"value": "<string>",
"type": "<string>",
"primary": true
}
],
"name": {
"formatted": "<string>",
"familyName": "<string>",
"givenName": "<string>",
"middleName": "<string>",
"honorificPrefix": "<string>",
"honorificSuffix": "<string>"
},
"displayName": "<string>",
"nickName": "<string>",
"title": "<string>",
"preferredLanguage": "<string>",
"department": "<string>",
"organization": "<string>",
"timezone": "<string>",
"phoneNumbers": [
{
"value": "<string>",
"type": "<string>",
"primary": true
}
],
"active": true
}'

The data passed in emails.value is same as in the existing account with userId

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 22, 2021

Hello Mrinalini,

Thank you for your reply. If you need to update the user details without changing the email, you can use PATCH instead

Can you try that and let me know if you have any trouble?

Shannon

Like # people like this
Mrinalini Pal July 22, 2021

Thank you Shannon. It works like a charm.

Like Shannon S likes this
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 22, 2021

Hi Mrinalini,

That's great. Thank you for confirming. I'm happy to hear it worked.

Take care, and have a pleasant rest of your week.

Shannon

Like Dario B likes this
0 votes
Tom Maes June 27, 2023

Hello,

When we update a mail adres by the patch instead, we've get an 405 error: Method is not allowed.

curl --request PATCH\
--url 'https://api.atlassian.com/scim/directory/{directoryId}/Users/{userId}' \
--header 'Authorization: Bearer <access_token>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
{
"schemas":[
"urn:ietf:params:scim:api:messages:2.0:PatchOp"
],
"operations": [
{
"op""replace",
"path""emails.value",
"value""{EMAIL}"
}
]
}
}
Result:
{
    "timestamp""2023-06-26T15:13:15.006+00:00",
    "status"405,
    "error""Method Not Allowed",
    "message""Method Not Allowed",
    "path""/api/scim/directory/{directory-id}/Users"
}
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 27, 2023

Hi Tom,

Good afternoon. Thanks for following up on this question. First, I edited your API call to remove identifying information. Please note this is an open forum, and the public can view anything you post here.

I understand you're getting a 405 Method Not Allowed error when you try to patch (change) an email address from one of your managed accounts.

Can you confirm you're using the organization admin API key? See Manage an organization with the admin APIs. This is different from the key you generate for your user account.

If you can confirm you're using the org admin API key and not your user API key, I recommend raising a ticket with the Atlassian Access support team

Let me know if you have any trouble with that.

Take care,

Shannon S | Atlassian Cloud support

Like Tom Maes likes this

Suggest an answer

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

Atlassian Community Events