Microsoft Graph Beta - 用户更新 - 目标实体集目前不支持请求

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

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 本地 DateTimeDateTimeOffSet 时出现以下错误。所以,这也不应该成为问题。 问题:错误的可能原因是什么,如何解决?

错误:

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

代码:

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);
}

根据一些测试,我遇到了和你一样的问题。我在代码中使用 client_credential grant flow 和 username/password grant flow(并添加了足够的权限)对其进行了测试,但其中 none 成功了。然后我在图形资源管理器中测试它但也失败了。 属性 hireDate 好像无法更新成功

顺便说一句,我找到了另一个属性也许你可以用,你可以用employeeHireDate。我已经测试更新这个 属性,它工作正常。这个属性只是在我们使用beta graph api时存在,我们在v1.0 user properties nor in beta user properties文档中也找不到它。

在代码中更新employeeHireDate,请参考下面的代码:

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);

顺便说一句,你需要注意测试版的属性,因为它可能会在未来发生变化

====================================更新 ==================================

截至目前,我们可以通过图表API

更新雇佣日期(员工雇佣日期)属性

补丁 https://graph.microsoft.com/beta/users/userid

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

请参考Github and UserVoice

中已经提出的这个问题