Skip to content

az rest --headers not taken into account when $expand'ing Microsoft Graph API #26544

@timmkrause

Description

@timmkrause

Describe the bug

When querying the Microsoft Graph API utilizing the $search parameter a special header needs to be set (see error message). When additionally applying $expand the correctly provided header does not seem to be taken into account anymore.

Command Name
az rest

Errors:

Bad Request({"error":{"code":"Request_UnsupportedQuery","message":"Request with $search query parameter only works through MSGraph with a special request header: 'ConsistencyLevel: eventual'","innerError":{"date":"2023-05-26T07:16:39","request-id":"...","client-request-id":"..."}}})

To Reproduce:

$select = '$select=displayName'
$filterTest = '$search=\"displayName:MySearchString\"'
$expand = '$expand=appRoleAssignedTo'

✔ Works:

az rest `
    --method GET `
    --headers ConsistencyLevel=eventual `
    --uri "https://graph.microsoft.com/v1.0/servicePrincipals" `
    --url-parameters $filterTest $select

❌ Does not work because of adding $expand:

az rest `
    --method GET `
    --headers ConsistencyLevel=eventual `
    --uri "https://graph.microsoft.com/v1.0/servicePrincipals" `
    --url-parameters $filterTest $select $expand

--verbose shows that the header is set correctly.

Expected Behavior

Should work with $expanding as well.

Environment Summary

Windows-10-10.0.19045-SP0
Python 3.10.10
Installer: MSI

azure-cli 2.49.0

Extensions:
account 0.2.5
containerapp 0.3.31

Dependencies:
msal 1.20.0
azure-mgmt-resource 22.0.0

Additional Context

Maybe $expanding leads to subsequent requests where the header is not being forwarded to anymore?

Metadata

Metadata

Assignees

Labels

Auto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamGraph(doesn't work with label-triggered comments; use Graph.Microsoft instead) az adService AttentionThis issue is responsible by Azure service team.act-identity-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionThis issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions