How to update the users birthday
Asked Answered
D

4

6

I want to update the birthday of a user using the patch request. Updating other properties works as expected but the moment the birthday property is included, the following error returned:

The request is currently not supported on the targeted entity set

I already tried to update the user to be sure the permissions are fine.

Application permissions are used.

This PATCH request to /V1.0/users/{id} works:

{
  "givenName": "Fridas"
}

Passing this request body however:

{
  "givenName":"Fridas",
  "birthday" : "2014-01-01T00:00:00Z
}

throws an error

{
  "error":
  {
    "code":"BadRequest",
    "message":"The request is currently not supported on the targeted entity set",
    "innerError":
    {
      "request-id":"5f0d36d1-0bff-437b-9dc8-5579a7ec6e72",
      "date":"2019-08-13T15:27:40"
    }
  }
}

When I update the birthday separately, I get a 500 error. Print screens below. Updating the user id works fine, birthday does not. Same user id is used in the request. enter image description here

enter image description here

Dinka answered 13/8, 2019 at 15:29 Comment(0)
R
2

I'm not sure why this happens, but a workaround, albeit an annoying one, is to update birthday separately from other attributes.

E.g.

PATCH https://graph.microsoft.com/v1.0/users/userid
{  
  "birthday" : "2014-01-01T00:00:00Z"
}

Here is a screenshot from MS Graph Explorer: enter image description here

Radium answered 13/8, 2019 at 18:6 Comment(5)
I tried to do this but then got a 500 error. Print screens are attached to the original question.Dinka
@Dinka Hm that's odd. Did you check in Active Directory to see if the user exists there? Also it takes ~15 minutes for a user to propagate after being created, so did you wait that long to test?Radium
The user is created on "createdDateTime": "2019-04-24T13:07:10Z" so that should be long enough between now and then :-) Also checked in azure ad, user exists there. I can update properties like mobilePhone, givenName etc but not the birthday.Dinka
Do you have the correct API permissions? If you create a new user in the O365 admin site, can you change that user's birthday?Radium
The API has the following permissions:"roles": [ "User.ReadWrite.All", "Directory.ReadWrite.All", "Group.ReadWrite.All", "EduRoster.ReadWrite.All", "Member.Read.Hidden" ] I have an admin account in O365 but don't see any way to change the birthday in the O365 Admin site for other users. For my own account it's possible.Dinka
M
2

In fact, this is a limitation in the current system.

User is a composite type. Under the covers some properties in user are mastered by different services, and we currently don't support updates across multiple services.

"birthday" is not mastered by Azure AD. So we can't update it with other properties mastered by Azure AD in the same call.

It is strongly recommended that you update this property separately. I can update it from my side. So you need a backend engineer to track this request for you.

Madcap answered 21/8, 2019 at 1:43 Comment(0)
E
1

This seems to affect more than Birthday. Skills[] and Responsibilities[] are also returning 500 Internal Server Error when using PATCH request via REST API with:

{"skills": ["TESTING", "ANOTHER SKILL"]}

Same happens via the GraphServiceClient - except the result is:

Failed to call the Web Api: InternalServerError
Content: {
"error": {"code": "-1, Microsoft.Office.Server.Directory.DirectoryObjectUnauthorizedAccessException",
"message": "Attempted to perform an unauthorized operation.",
"innerError": {
  "request-id": "1c2ccc54-0a0c-468f-a18c-6bdfbad4077d",
  "date": "2019-08-28T13:23:55"
    }}}

These requests work on the Graph Explorer page, but not via calls to the API.

Ethicize answered 28/8, 2019 at 13:27 Comment(0)
E
0

For anybody still struggling with this, I added the permission User.ManageIdentities.All to my app registration and it works to update users' birthdays. Without that permission, I could only patch my own

Elanorelapid answered 12/7, 2024 at 22:54 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.