Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,862 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Error - {The expression cannot be evaluated. A common cause of this error is attempting to pass a lambda into a delegate.}
Here is code I am using
var requestBody = new User
{
AccountEnabled = true,
DisplayName = "Display Name",
GivenName = "Display",
Mail = "cccccccccc@gmail.com",
Surname = "Name",
UserPrincipalName = "cccccccccc@gmail.com"
};
var result = await _appClient.Users.PostAsync(requestBody);
```I followed the tutorial here ([https://learn.microsoft.com/en-us/graph/tutorials/dotnet-app-only?tabs=aad](https://learn.microsoft.com/en-us/graph/tutorials/dotnet-app-only?tabs=aad)) and ([https://learn.microsoft.com/en-us/graph/api/user-post-users?view=graph-rest-1.0&tabs=csharp](https://learn.microsoft.com/en-us/graph/api/user-post-users?view=graph-rest-1.0&tabs=csharp)) Everything works but when I add my custom code as above, it fails with error.
**{The expression cannot be evaluated. A common cause of this error is attempting to pass a lambda into a delegate.}**
You cannot use consumer ID values for the UserPrincipalName property. It needs to match a domain within your Entra tenant, i.e. ccccccccc@tenant.onmicrosoft.com
It does not work. Even after removing the UserPrincipalName it fails.