msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Expect simple name=value query, but observe property 'assignedLicenses' of complex type 'AssignedLicense'. when using filter and expand property

Open AdrianStefaniak opened this issue 1 year ago • 2 comments

Thanks for reporting the bug. Please ensure you've gone through the following checklist before opening an issue:

  • Make sure you can reproduce this issue using the latest released version of Microsoft.Graph or Microsoft.Graph.Beta.
  • Please search the existing issues to see if there has been a similar issue filed.
  • For issues related to authentication and service errors, please refer to our troubleshooting guide. For service issues, please open a question at https://developer.microsoft.com/graph/support.

Describe the bug I get an error: Get-MgUser : Expect simple name=value query, but observe property 'assignedLicenses' of complex type 'AssignedLicense'.

I think this is bug because:

  1. If I run Get-MgUser -Filter "assignedLicenses/`$count ne 0" -CountVariable CountVar -ConsistencyLevel eventual |select-object UserPrincipalName I get list of users with license, so I know the filter is working
  2. If I run Get-MgUser -CountVariable CountVar -ConsistencyLevel eventual -ExpandProperty TransitiveMemberOf | select-object UserPrincipalName, TransitiveMemberOf I get users with their transitive membership.

I thought maybe advanced filter and -expandproperty do not work together, but running other advanced filtering like: Get-MgUser -Filter "proxyAddresses/any(x:x eq 'smtp:<emailAddress>')" -CountVariable CountVar -ConsistencyLevel eventual -ExpandProperty TransitiveMemberOf | select-object userprincipalname, transitivememberOf

works fine and returns results. To Reproduce Steps to reproduce the behavior:

  1. Execute
    Get-MgUser -Filter "assignedLicenses/`$count ne 0" -CountVariable CountVar -ConsistencyLevel eventual -ExpandProperty TransitiveMemberOf |select-object UserPrincipalName, TransitiveMemberOf

Expected behavior I should get response containing list of users without assigned license. This list should contain userprincipalname, TransitiveMemberOf

Debug Output DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'. DEBUG: [Authentication]: - Scopes: DEBUG: ============================ HTTP REQUEST ============================

HTTP Method: GET

Absolute Uri: https://graph.microsoft.com/v1.0/users?$filter=assignedLicenses/$count ne 0&$count=true&$expand=TransitiveMemberOf

Headers: ConsistencyLevel : eventual FeatureFlag : 00000043 Cache-Control : no-store, no-cache User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.19045; en-GB),PowerShell/5.1.19041.3693 Accept-Encoding : gzip SdkVersion : graph-powershell/2.2.0 client-request-id :

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code: BadRequest

Headers: Transfer-Encoding : chunked Vary : Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id : client-request-id : x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"UK South","Slice":"E","Ring":"3","ScaleUnit":"001","RoleInstance":"LN2PEPF000107BA"}} x-ms-resource-unit : 3 Cache-Control : no-cache Date : Mon, 12 Feb 2024 11:41:17 GMT

Body: { "error": { "code": "Request_BadRequest", "message": "Expect simple name=value query, but observe property 'assignedLicenses' of complex type 'AssignedLicense'.", "innerError": { "date": "2024-02-12T11:41:18", "request-id": "", "client-request-id": "" } } }

Confirm Expect simple name=value query, but observe property 'assignedLicenses' of complex type 'AssignedLicense'.

Status: 400 (BadRequest) ErrorCode: Request_BadRequest Date: 2024-02-12T11:41:18

Headers: Transfer-Encoding : chunked Vary : Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id : client-request-id : x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"UK South","Slice":"E","Ring":"3","ScaleUnit":"001","RoleInstance":"LN2PEPF000107BA"}} x-ms-resource-unit : 3 Cache-Control : no-cache Date : Mon, 12 Feb 2024 11:41:17 GMT

[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): A Get-MgUser : Expect simple name=value query, but observe property 'assignedLicenses' of complex type 'AssignedLicense'. Status: 400 (BadRequest) ErrorCode: Request_BadRequest Date: 2024-02-12T11:41:18 Headers: Transfer-Encoding : chunked Vary : Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id : client-request-id : x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"UK South","Slice":"E","Ring":"3","ScaleUnit":"001","RoleInstance":"LN2PEPF000107BA"}} x-ms-resource-unit : 3 Cache-Control : no-cache Date : Mon, 12 Feb 2024 11:41:17 GMT At line:1 char:1

  • Get-MgUser -Filter "assignedLicenses/`$count ne 0" -CountVariable Cou ...
  •   + CategoryInfo          : InvalidOperation: ({ ConsistencyLe...stem.String[] }:<>f__AnonymousType40`8) [Get-MgUser_List], Exception
      + FullyQualifiedErrorId : Request_BadRequest,Microsoft.Graph.PowerShell.Cmdlets.GetMgUser_List
    

DEBUG: [CmdletEndProcessing]: - Get-MgUser end processing. Module Version Get-Module Microsoft.Graph*

ModuleType Version Name ExportedCommands


Script 2.2.0 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext...} Script 2.2.0 Microsoft.Graph.Users {Get-MgUser, Get-MgUserCount, Get-MgUserCreatedObject, Get-MgUserCreatedObjectAsServicePrincipal...}

Environment Data Name Value


PSVersion 5.1.19041.3693 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.3693 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context If this is not a bug, but expected behavior, messaging could be more clear, as currently I am not sure what is wrong with filter, as it is working fine in other scenarios.

AdrianStefaniak avatar Feb 12 '24 11:02 AdrianStefaniak

Hi Adrian,

It seems like this is probably a Graph API issue. I can make that assumption by taking the absolute URI from your debug and popping that into Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer).

https://graph.microsoft.com/v1.0/users?$filter=assignedLicenses/$count ne 0&$count=true&$expand=TransitiveMemberOf

image

I get the exact same error message you do, so it's unlikely to be the Graph SDK at fault here. I'm no dev, but I would recommend you head on over to https://developer.microsoft.com/en-us/graph/support to raise the question with the Graph API devs.

SeniorConsulting avatar Feb 12 '24 19:02 SeniorConsulting

Thank you @SeniorConsulting, I also got the same results while using graph explorer. This is indeed a service issue. @AdrianStefaniak, for API related issues/questions we are not best placed to give an answer. Kindly raise an issue here https://developer.microsoft.com/en-us/graph/support so that the API owner can respond to it.

timayabi2020 avatar Mar 01 '24 10:03 timayabi2020

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.