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

Retrieving the Status Code & Response Header without -Debug #1452

Closed
potluri96 opened this issue Aug 10, 2022 · 2 comments
Closed

Retrieving the Status Code & Response Header without -Debug #1452

potluri96 opened this issue Aug 10, 2022 · 2 comments

Comments

@potluri96
Copy link

Hello,

How do I get the status code and response header when invoking "Invoke-MgGraphRequest" without -Debug

Invoke-MgGraphRequest

@ghost ghost added the ToTriage label Aug 10, 2022
@peombwa
Copy link
Member

peombwa commented Aug 12, 2022

@potluri96, you can use:

  • -ResponseHeadersVariable ResponseHeader and access it as variable via $ResponseHeader. See Get-Help Invoke-MgGraphRequest -Parameter ResponseHeadersVariable.
  • -StatusCodeVariable for status code.

@Mike-Crowley
Copy link

BTW, this parameter seems to populate only if the connection is successful, making it pretty useless.

For example, if I do two calls, one that works and one that doesn't, and and send the status code to a $statusCode variable, the second (failed) call will not return a status, so the variable will remain '200'.

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