How to update the users birthday

亡梦爱人 提交于 2021-01-27 13:08:23

问题


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.


回答1:


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:




回答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.




回答3:


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.



来源:https://stackoverflow.com/questions/57481004/how-to-update-the-users-birthday

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!