Microsoft Graph Beta - User Update - request is currently not supported on the targeted entity set

1

I get the following error when Updating a user using Microsoft Graph Beta. Permissions should not be an issue as I'm using the following permissions: user.readwrite.all, directory.readwrite.all. Also, HireDate is of type DateTimeOffSet that I'm getting by converting local DateTime to DateTimeOffSet. So, that should not be an issue either. Question: What could be the cause of the error and how can it be fixed?

Error:

Microsoft.Graph.ServiceException
  HResult=0x80131500
  Message=Code: BadRequest
Message: The request is currently not supported on the targeted entity set

Inner error:
    AdditionalData:
    date: 2020-08-31T13:59:10
    request-id: 4b62576f-6572-414c-b9ef-07ea9a61c101
ClientRequestId: 4b62576f-6572-414c-b9ef-07ea9a61c101

Code:

private async void DataGridUserUpdateButton_Click(object sender, RoutedEventArgs e)
{
  GraphServiceClient graphClient = new GraphServiceClient(authProvider);

  User user = (sender as Button).DataContext as User;

  string id = user.UserPrincipalName;

   var user = new User
   {
     Department = "IT",
     DisplayName = "Bob Doe",
     HireDate = new DateTime(2020, 8, 31, 2, 30, 0),
     JobTitle = "IT Manager"
   };

  await graphClient.Users[sId]
            .Request()
            .UpdateAsync(user);
}
azure-active-directory
microsoft-graph-api
microsoft-graph-sdks
asked on Stack Overflow Aug 31, 2020 by nam

2 Answers

0

According to some test, I met the same issue as yours. I test it in code with both client_credential grant flow and username/password grant flow(and add enough permissions) but none of them succeeded. Then I test it in graph explorer but also failed. It seems the property hireDate can't be updated success.

For a wordaround, I found another property maybe you can use, you can use employeeHireDate. I already test to update this property, it works fine. This property just exists when we use beta graph api and we can't find it neither in v1.0 user properties nor in beta user properties document.

To update employeeHireDate in code, please refer to the code below:

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var user = new User
{
    AdditionalData = new Dictionary<string, object>()
    {
        {"employeeHireDate", "2019-01-01T00:00:00Z"}
    }
};

await graphClient.Users["userId"]
    .Request()
    .UpdateAsync(user);

By the way, you need to pay attention to the properties in beta version because it may be changed in future.

==================================Update==================================

enter image description here

answered on Stack Overflow Sep 1, 2020 by Hury Shen • edited Sep 4, 2020 by Hury Shen
0

As of now, we can update the hire date(employee hire date) property through Graph API

Patch https://graph.microsoft.com/beta/users/userid

{"employeeHireDate":"2020-01-02T00:00:00Z"}

Please refer to this issue which is already raised in Github and UserVoice

answered on Stack Overflow Sep 8, 2020 by Sruthi J

User contributions licensed under CC BY-SA 3.0