无法通过单个请求更新用户的多个属性

Unable to update multiple properties on a user with a single request

我无法更新以下任何用户属性 (SharePoint Online): 关于我、生日、雇用日期、兴趣、我的网站、过去的项目、首选姓名、职责、学校、技能。在一个请求中使用其他用户属性。按照文档。

https://docs.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=http

例如:

    public async Task UpdateUserTask(string userId)
    {
        User user = new User
        {
            AboutMe = "Im dev",
            GivenName = "Some One"
        };

        var _graphClient = GetGraphServiceClient();

        await _graphClient.Users[userId].Request().UpdateAsync(user);
    }

GetGraphServiceClient 的实现:

https://docs.microsoft.com/en-us/graph/sdks/choose-authentication-providers?tabs=CS#client-credentials-provider

private GraphServiceClient GetGraphServiceClient()
    {
        string tenantId = "{myTenantId}";
        string clientId = "{myClientId}";
        string clientSecret = "{myClientSecret}";

        string[] scopes = new[]
        {
            "https://graph.microsoft.com/.default",
        };

        TokenCredentialOptions options = new TokenCredentialOptions
        {
            AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
        };

        ClientSecretCredential clientSecretCredential = new ClientSecretCredential(
            tenantId, clientId, clientSecret, options);

        return new GraphServiceClient(clientSecretCredential, scopes);
    }

回复:

Code: BadRequest.
Message: The request is currently not supported on the targeted entity set

虽然如果您单独更新这些属性,它们会成功更新(AboutMe 和 GivenName)

我有:

API写入和更改数据的权限:

和全局管理规则。

有没有办法使用单个请求更新这些属性?

如有任何答复,我将不胜感激:)

如果您在 Microsoft Graph 资源管理器中进行相同的查询,结果不会改变

https://graph.microsoft.com/v1.0/users/{userId}
{
    "aboutMe": "Im dev",
    "givenName": "Someone"
}

documentation 中有一条注释,只有应用程序权限的应用无法更新以下属性:

aboutMebirthdayemployeeHireDateinterestsmySitepastProjectspreferredNameresponsibilitiesschoolsskills.

这正是你的情况,因为你只向 Azure 中的应用程序添加了应用程序权限。

更新

另一个限制可能是 User 是复合类型,一些属性由不同的服务覆盖,Graph API 不支持跨多个服务的更新。

根据 this User Azure AD 中的对象具有以下属性:

accountEnabledageGroupassignedLicensesassignedPlansassignedPlansassignedPlansbusinessPhonescity, companyName, consentProvidedForMinor, country, createdDateTime, createdObjects, creationType, department, displayName , employeeHireDate, employeeId, employeeOrgData, employeeOrgData, employeeType, externalUserState, faxNumber, givenName, identities, imAddresses, isResourceAccount, jobTitle, mail, mailNickname, manager, mobilePhone, officeLocation, onPremisesExtensionAttributes, onPremisesImmutableId, onPremisesLastSyncDateTime, onPremisesProvisioningErrors, onPremisesProvisioningErrors, onPremisesSamAccountName, onPremisesSecurityIdentifier, onPremisesSyncEnabled, otherMails, passwordPolicies, passwordProfile, postalCode, preferredLanguage, provisionedPlans,provisionedPlans proxyAddresses, showInAddressList, state, streetAddress, surname, usageLocation, userPrincipalName, userType

更新 User 时,这些属性无法与 Sharepoint Online 属性一起更新。

aboutMebirthdayhireDateinterestsmySitepastProjectspreferredNameresponsibilitiesschoolsskills