GraphServiceClient UpdateAsync() throwing error Resource '' does not exist or one of its queried reference-property objects are not present

605 views Asked by At

I am using below code to update custom extension claim attribute but it is not working.

GraphServiceClient UpdateAsync() method throwing error

  var graphServiceClient = new GraphServiceClient(new DelegateAuthenticationProvider((requestMessage) =>
            {
               requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", graphapitoken);
                return Task.FromResult(0);
            }));

var  dictionary = new System.Collections.Generic.Dictionary<string, object>();
            dictionary ["extension_clientid_moviename"] = "SampleValue";

 await graphServiceClient.Users["[email protected]"] // here I'm getting error 
                .Request()
                .UpdateAsync(new User()
                {
                    AdditionalData = dictionary
                });

Error:

Code: Request_ResourceNotFound\r\nMessage: Resource '[email protected]' does not exist or one of its queried reference-property objects are not present.

Update 1:

I have created extensions following below article.

https://www.rahulpnath.com/blog/azure-ad-custom-attributes-and-optional-claims-from-an-asp-dot-net-application/

I have used Powershell commands to create extensions.

extension_clientid_moviename is the extension name.

1

There are 1 answers

4
Tony Ju On

For guest users, you can not use their email to request a user, you should use their Object ID instead.

enter image description here

Also, you can add custom data to resources using extensions.

Update:

You need User.ReadWrite.All permission.

enter image description here

Go to Azure portal->App registrations->your application->API permissions to check if you have added the permission and granted admin consent.