I was unable to update any of the following user properties(SharePoint Online): aboutMe, birthday, hireDate, interests, mySite, pastProjects, preferredName, responsibilities, schools, skills. With other user properties in one request. Following the documentation.
https://learn.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=http
For example:
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);
}
Implementation of GetGraphServiceClient:
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);
}
Response:
Code: BadRequest.
Message: The request is currently not supported on the targeted entity set
Although if you update these properties separately, they are successful updated (AboutMe and GivenName)
What I have:
API permissions for writing and changing data:
And global admin rule.
Is there a way to update these properties using a single request?
I will be grateful for any answer :)
If you make the same query in Microsoft Graph Explorer, the result will not change
https://graph.microsoft.com/v1.0/users/{userId}
{
"aboutMe": "Im dev",
"givenName": "Someone"
}
There is a note in the documentation that the following properties cannot be updated by an app with only application permissions:
aboutMe
, birthday
, employeeHireDate
, interests
, mySite
, pastProjects
, preferredName
, responsibilities
, schools
, and skills
.
Which is exactly your case because you've added only application permissions to your app in Azure.
Update
Another limitation can be that User
is a composite type and some properties are covered by different services and Graph API doesn't support updates across multiple services.
According this User
object in Azure AD has the following properties:
accountEnabled
, ageGroup
, assignedLicenses
, assignedPlans
, assignedPlans
, assignedPlans
, businessPhones
, city
, 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
When updating User
, those properties cannot be updated together with Sharepoint Online properties.
aboutMe
, birthday
, hireDate
, interests
, mySite
, pastProjects
, preferredName
, responsibilities
, schools
, skills