Open beth-panx opened 4 years ago
Hello beth-panx, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌
@beth-panx @shweaver-MSFT
I would like to use mgt-get to get the manager chain up to the root level https://docs.microsoft.com/en-us/graph/api/user-list-manager?view=graph-rest-1.0&tabs=http#example-2-get-manager-chain-up-to-the-root-level, and that requires ConsistencyLevel: eventual
be sent in the request headers.
This is a feature I want to see!
Agree, this features would make the component much better. What do you think about adding the header property like so:
<mgt-get resource="bla" headers="key:value, key:value" />
I believe this should be fairly straightforward to implement?
That would be fine!
I am not an expert in this, so apologies if this isn't what you are asking about. I found that if you are using the providers built into the toolkit, you can simply do something like this to add request headers to all mgt-get component requests without having to re-initialize the graph client and re-create the middleware chain:
Providers.globalProvider.graph.client.config.fetchOptions = {headers: {'Prefer': 'IdType="ImmutableId"'}}
(obviously change the request headers to whatever you want)
I should also note, you can even do this after the provider has been initialized. Any subsequent calls after you set the fetchOptions will include the headers in the request.
Also, if you are loading the provider via a HTML provider component tag like this for example:
<script src="https://unpkg.com/@microsoft/mgt@2/dist/bundle/mgt-loader.js"></script>
<mgt-msal2-provider client-id="YOUR_CLIENT_ID"></mgt-msal2-provider>
You can access the globalProvider object like this:
mgt.Providers.globalProvider.graph.client.config.fetchOptions = {headers: {'Prefer': 'IdType="ImmutableId"'}}
You are absolutely right. This works, but will impact all future calls. I think a more sustainable solution would be a way to provide headers on the component itself, but it's a great workaround while we figure out a good way to bring this feature.
FYI @gavinbarron
Related to #1723
Proposal: Add support for headers in mgt-get
Description
To support api's such as List users beta
Rationale
There are times graph api supports passing of additional headers. Right now mgt-get doesn't have this as an option. Developer will need to overwrite the graph client to achieve this.
Preferred Solution
Add header attribute or property