Azure / Azure/azure-cli

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

Open
#26,544 2 comments 0 reactions 1 assignee Claimed by @jiasli View on GitHub
act-identity-squad Auto-Assign Azure CLI Team customer-reported Graph needs-team-attention question Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

## 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 `$expand`ing 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 `$expand`ing leads to subsequent requests where the header is not being forwarded to anymore?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.