Title: Breaking change: Invoke-WebRequest -ContentType with empty string now fails · Issue #11396 · PowerShell/PowerShell · GitHub
Open Graph Title: Breaking change: Invoke-WebRequest -ContentType with empty string now fails · Issue #11396 · PowerShell/PowerShell
X Title: Breaking change: Invoke-WebRequest -ContentType with empty string now fails · Issue #11396 · PowerShell/PowerShell
Description: Steps to reproduce Unfortunately I don't have a simple repro at hand, but the change is that passing an empty string for the -ContentType parameter of Invoke-WebRequest used to work, through 6.2.3, but now it fails. I'm using a popular i...
Open Graph Description: Steps to reproduce Unfortunately I don't have a simple repro at hand, but the change is that passing an empty string for the -ContentType parameter of Invoke-WebRequest used to work, through 6.2.3,...
X Description: Steps to reproduce Unfortunately I don't have a simple repro at hand, but the change is that passing an empty string for the -ContentType parameter of Invoke-WebRequest used to work, through 6....
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/11396
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Breaking change: Invoke-WebRequest -ContentType with empty string now fails","articleBody":"\u003c!--\r\n\r\nFor Windows PowerShell 5.1 issues, suggestions, or feature requests please use the following link instead:\r\nWindows PowerShell [UserVoice](https://windowsserver.uservoice.com/forums/301869-powershell)\r\n\r\nThis repository is **ONLY** for PowerShell Core 6 and PowerShell 7+ issues.\r\n\r\n- Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- Search the existing issues.\r\n- Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- Refer to the [known issues](https://docs.microsoft.com/powershell/scripting/whats-new/known-issues-ps6?view=powershell-6).\r\n\r\n-->\r\n\r\n# Steps to reproduce\r\nUnfortunately I don't have a simple repro at hand, but the change is that passing an empty string for the `-ContentType` parameter of `Invoke-WebRequest` used to work, through 6.2.3, but now it fails.\r\n\r\nI'm using a popular internal module that makes calls to the Azure DevOps web service. It has an internal function that accepts a `[string] $ContentType` parameter, which then gets passed on to `Invoke-WebRequest`. When there is no body to send, and thus no content type, the calling code passes `$null` for `$ContentType`, but since the parameter type is `[string]`, it gets converted to an empty string. The same thing happens in PS5.1. In PS5.1, passing in the empty string works (it treats it as no content type), and the same in PsCore 6. But on PSv7:\r\n\r\n# Actual behavior\r\n\r\n```none\r\nThe cmdlet cannot run because the -ContentType parameter is not a valid Content-Type header. Specify a valid Content-Type for -ContentType, then retry. To suppress header validation, supply the -SkipHeaderValidation parameter.\r\n```\r\n# Expected behavior\r\n\r\n(no error)\r\n\r\nI don't know if this is worth breaking the glass on the RC, but at a minimum, because this is a heavily-used, workhorse cmdlet, I think it should be documented.\r\n\r\n# Environment data\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\r\n\r\n```none\r\nName Value\r\n---- -----\r\nPSVersion 7.0.0-rc.1\r\nPSEdition Core\r\nGitCommitId 7.0.0-rc.1\r\nOS Microsoft Windows 10.0.19041\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n","author":{"url":"https://github.com/jazzdelightsme","@type":"Person","name":"jazzdelightsme"},"datePublished":"2019-12-18T16:06:07Z","url":"https://github.com/PowerShell/PowerShell/issues/11396"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:b5d62c6a-90c1-fb32-219b-df6fa50380e8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DF4:15BFB5:1D00BF:276773:6AFD5050 |
| html-safe-nonce | 99388f358444076b89e5e213c3b5117f566b5fbe88ad92a72dfb134aaae6870a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REY0OjE1QkZCNToxRDAwQkY6Mjc2NzczOjZBRkQ1MDUwIiwidmlzaXRvcl9pZCI6IjQwNDY3Nzg2MTM5ODEwNzM0ODkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fa591f1e16aacc120393b67cd97f671d57ec135f3611241652612513fd9aabec |
| hovercard-subject-tag | issue:539774430 |
| 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/11396/issue_layout |
| twitter:image | https://opengraph.githubassets.com/34aedcf54df8087cd657a66fdb15bb65a7d542f2f1c5f946dbd1ad76ecfa8e65/PowerShell/PowerShell/issues/11396 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/34aedcf54df8087cd657a66fdb15bb65a7d542f2f1c5f946dbd1ad76ecfa8e65/PowerShell/PowerShell/issues/11396 |
| og:image:alt | Steps to reproduce Unfortunately I don't have a simple repro at hand, but the change is that passing an empty string for the -ContentType parameter of Invoke-WebRequest used to work, through 6.2.3,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jazzdelightsme |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| 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 | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width