Title: Allow Capture of Response Headers with Invoke-RestMethod · Issue #4845 · PowerShell/PowerShell · GitHub
Open Graph Title: Allow Capture of Response Headers with Invoke-RestMethod · Issue #4845 · PowerShell/PowerShell
X Title: Allow Capture of Response Headers with Invoke-RestMethod · Issue #4845 · PowerShell/PowerShell
Description: Problem Invoke-RestMethod is extremely useful for working with APIs that return parsable objects. My single gripe has been that it is not possible to capture the response headers. Many API's provide (sometimes critical) details via the r...
Open Graph Description: Problem Invoke-RestMethod is extremely useful for working with APIs that return parsable objects. My single gripe has been that it is not possible to capture the response headers. Many API's provid...
X Description: Problem Invoke-RestMethod is extremely useful for working with APIs that return parsable objects. My single gripe has been that it is not possible to capture the response headers. Many API's pr...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/4845
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow Capture of Response Headers with Invoke-RestMethod","articleBody":"# Problem\r\n\r\n`Invoke-RestMethod` is extremely useful for working with APIs that return parsable objects. My single gripe has been that it is not possible to capture the response headers. Many API's provide (sometimes critical) details via the response headers, especially rate-limiting quotas and session timeouts. In situations where information in the the response headers are required, the user must currently fall back to `Invoke-WebRequest` and then perform their own Content-Type detection and response-to-object conversion.\r\n\r\n# Proposal\r\n\r\nAdd a `-ResponseHeadersVariable` parameter to the Web Cmdlets that accepts string. this string will be used as the name of a variable in the calling scope. This variable will be set with the same contents of `BasicHtmlWebResponseObject.Headers`. The user can then access the variable to retrieve the headers from the previews call to `Invoke-RestMethod`\r\n\r\nExample:\r\n\r\n```powershell\r\n$GetData = Invoke-RestMethod -Uri 'http://localhost:8083/Get/' -ResponseHeadersVariable 'ResonseHeaders'\r\n$ResponseDate = [DateTime]$ResonseHeaders.Date[0]\r\n```\r\n\r\nThis example converts the `Date` response header to a `DateTime`.\r\n\r\nThe functionality would be similar to `-SessionVariable`. This would be available for both Web Cmdlets, though it would be redundant on `Invoke-WebRequest` as it would be a mirror of the returned `Headers` property.","author":{"url":"https://github.com/markekraus","@type":"Person","name":"markekraus"},"datePublished":"2017-09-15T11:41:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/4845/PowerShell/issues/4845"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:51d07e10-bfe5-fd14-fe30-76e30a600827 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 81D4:63422:1859F12:2350C6D:6A5789E7 |
| html-safe-nonce | 6feadee2c7c938767c65bbe1ccb446f9c57fad9ef19750ab949d3144dad32802 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MUQ0OjYzNDIyOjE4NTlGMTI6MjM1MEM2RDo2QTU3ODlFNyIsInZpc2l0b3JfaWQiOiIzOTI1MDI5ODU0NjM1MzMwMDIzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2f7ba9347ab52ed637777169de07dc7a5defdc7908026cccace30481951ea38f |
| hovercard-subject-tag | issue:258012346 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/4845/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c5cfc52db3fde0908e1bb645a73503069b8044c05ff7ba5204f35213dd4300b2/PowerShell/PowerShell/issues/4845 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c5cfc52db3fde0908e1bb645a73503069b8044c05ff7ba5204f35213dd4300b2/PowerShell/PowerShell/issues/4845 |
| og:image:alt | Problem Invoke-RestMethod is extremely useful for working with APIs that return parsable objects. My single gripe has been that it is not possible to capture the response headers. Many API's provid... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | markekraus |
| hostname | github.com |
| expected-hostname | github.com |
| None | c6353e56e94423c9cd5abde7708a859afa36a0c1203c73749055bf6ee6704cd0 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f59ab1c46b638204e2aea09126d089be5dc773b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width