Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow capture of HTTP response headers after a cmdlet is run #2394

Closed
joshtransient opened this issue Oct 30, 2023 · 5 comments
Closed

Allow capture of HTTP response headers after a cmdlet is run #2394

joshtransient opened this issue Oct 30, 2023 · 5 comments
Assignees

Comments

@joshtransient
Copy link

Is your feature request related to a problem? Please describe.
Since the guidance from MSFT is to use Graph API whenever possible to talk to SharePoint Online (since those requests are less subject to throttling than REST/CSOM), it would also help if the PowerShell module could either output HTTP headers so I can capture the recently-introducted IETF rate limiting headers.

Describe the solution you'd like
At the very least, I would like to be able to access response headers after calling a Graph API cmdlet. There are some other uses for this, particularly custom handling of HTTP 302s.

Much like PowerShell has the native -WarningVariable and -ErrorVariable arguments, it would be cool to have something like -ResponseHeadersVariable like the PWSH 7 version of Invoke-RestMethod has.

In a future state, after RateLimit gets a formally published spec, would really love to see those headers be taken into account for throttling control.

Describe alternatives you've considered
Writing a script that uses a lot of Invoke-WebRequest (for 5.1) or Invoke-RestMethod (for 7).

Additional context
As I understand it, the RateLimit-* headers only show up in the beta endpoints, and the IETF spec is still in draft status, so I know that getting this into the same pipeline that does throttling control for the other cmdlets is wishful thinking at this point. Simply returning the headers doesn't seem outside of the realm of possibility, though.

@timayabi2020
Copy link
Contributor

Hi @joshtransient as we plan around having the requested feature, the ideal work around would be to use Invoke-MgGraphRequest. i.e. Invoke-MgGraphRequest -Method GET -Uri "/v1.0/me" -RHV rh then grab the response header contents from $rh. Also see screenshot below.
image

@timayabi2020
Copy link
Contributor

Hi @joshtransient we have included the response headers inside a hashtable and you can easily access the response header parameter that you need. Please let us know if this works for you.

image

@CarolKigoonya
Copy link

#2600 to resolve this issue

@timayabi2020
Copy link
Contributor

Issue resolved in 2.15.0

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants