Skip to content

m365 entra user get sends incorrect query to Graph API #5788

@MartinM85

Description

@MartinM85

Priority

(Urgent) I can't use the CLI

Description

When running the command
m365 entra user get --id {user_id} --properties 'id,userPrincipalName,jobTitle,aboutMe' --withManager --debug

It fails with the error

The expression "id in ('{user_id}')" is not valid.

In debug I see that the query sent by CLI is

https://graph.microsoft.com/v1.0/users?$filter=id eq 
'{user_id}'&$select=id,userPrincipalName,jobTitle,aboutMe&$expand=manager($select=displayName,userPrincipalName,id,mail)

When calling /users endpoint there is a limitation on the Graph API side that some properties like aboutMe cannot be requested. Those properties can be read only when get user endpoint is called.

Check the doc (remark below the table)

The correct query generated by m365 entra user get should be

https://graph.microsoft.com/v1.0/users/{user_id}?$select=id,userPrincipalName,jobTitle,aboutMe&$expand=manager($select=displayName,userPrincipalName,id,mail)

Steps to reproduce

m365 entra user get --id {user_id} --properties 'id,userPrincipalName,jobTitle,aboutMe' --withManager --debug

Expected results

Command returns info about the specific user even if aboutMe, birthday, hireDate, interests, mySite, pastProjects, preferredName, responsibilities, schools, skills, or mailboxSettings property is specified in the option properties.

Actual results

Error: The expression "id in ('{user_id}')" is not valid.

Diagnostics

node.exe : Executing command entra user get with options 
{"options":{"id":"{user_id}","properties":"id,userPrincipalName,jobTitle,aboutMe","withManager":true,"debug":true,"output":"json"}}
At C:\Program Files\nodejs\m365.ps1:16 char:5
+     & "$basedir/node$exe"  "$basedir/node_modules/@pnp/cli-microsoft3 ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Executing comma...utput":"json"}}:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
- Running command...
Existing access token xxx still valid. Returning...
Request:
{
  "url": "https://graph.microsoft.com/v1.0/users?$filter=id eq 
'{user_id}'&$select=id,userPrincipalName,jobTitle,aboutMe&$expand=manager($select=displayName,userPrincipalName,id,mail)",
  "method": "get",
  "headers": {
    "Accept": "application/json;odata.metadata=none",
    "user-agent": "NONISV|SharePointPnP|CLIMicrosoft365/7.4.0",
    "accept-encoding": "gzip, deflate",
    "X-ClientService-ClientTag": "M365CLI:7.4.0",
    "authorization": "Bearer xxx"
  },
  "responseType": "json",
  "decompress": true
}
Request error:
{
  "url": "https://graph.microsoft.com/v1.0/users?$filter=id eq 
'{user_id}'&$select=id,userPrincipalName,jobTitle,aboutMe&$expand=manager($select=displayName,userPrincipalName,id,mail)",
  "status": 400,
  "statusText": "Bad Request",
  "headers": {
    "cache-control": "max-age=0, private",
    "transfer-encoding": "chunked",
    "content-type": "application/json",
    "vary": "Accept-Encoding",
    "strict-transport-security": "max-age=31536000",
    "request-id": "87ed1266-f68b-456c-a69b-233b291f459f",
    "client-request-id": "87ed1266-f68b-456c-a69b-233b291f459f",
    "x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"Germany West 
Central\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"002\",\"RoleInstance\":\"FR3PEPF00000442\"}}",
    "x-ms-resource-unit": "2",
    "date": "Mon, 22 Jan 2024 14:19:44 GMT"
  },
  "error": {
    "error": {
      "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
      "message": "The expression \"id in ('{user_id}')\" is not valid.",
      "innerError": {
        "date": "2024-01-22T14:19:44",
        "request-id": "87ed1266-f68b-456c-a69b-233b291f459f",
        "client-request-id": "87ed1266-f68b-456c-a69b-233b291f459f"
      }
    }
  }
}
Timings:
api: 363.7576ms
core: 8.9974ms
command: 393.3846ms
options: 0.1301ms
total: 403.2618ms
validation: 0.409ms
Error: The expression "id in ('{user_id}')" is not valid.

CLI for Microsoft 365 version

v7.4.0

nodejs version

v20.8.1

Operating system (environment)

Windows

Shell

Windows PowerShell

cli doctor

{
  "os": {
    "platform": "win32",
    "version": "Windows 11 Pro",
    "release": "10.0.22621"
  },
  "cliVersion": "7.4.0",
  "nodeVersion": "v20.8.1",
  "cliAadAppId": "b79e0f02-29c7-4d90-b3ef-f4d7817d467f",
  "cliAadAppTenant": "single",
  "authMode": "Secret",
  "cliEnvironment": "",
  "cliConfig": {},
  "roles": [
    "User.Read.All"
  ],
  "scopes": {}
}

Additional Info

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions