Title: Invoke-RestMethod doesn't include automatic ContentType value when not using POST method · Issue #16318 · PowerShell/PowerShell · GitHub
Open Graph Title: Invoke-RestMethod doesn't include automatic ContentType value when not using POST method · Issue #16318 · PowerShell/PowerShell
X Title: Invoke-RestMethod doesn't include automatic ContentType value when not using POST method · Issue #16318 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/16318
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invoke-RestMethod doesn't include automatic ContentType value when not using POST method","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nWhen using a POST, ContentType is automatically set to `application/x-www-form-urlencoded`\r\n```\r\n invoke-restmethod https://webhook.site/6a5097af-3644-4462-9d92-d910088d2f4d -Method POST -Body @{ Test = \"test\" }\r\n```\r\n\r\nWhen using other methods, it is not. It is blank. \r\n\r\n```\r\n invoke-restmethod https://webhook.site/6a5097af-3644-4462-9d92-d910088d2f4d -Method PUT -Body @{ Test = \"test\" }\r\n```\r\n\r\n\r\n\r\n\r\n### Expected behavior\r\n\r\n```console\r\nI would expect that the content type would default to form encoded for all request methods (or at least for PUT). \r\n```\r\n\r\n\r\n### Actual behavior\r\n\r\n```console\r\nIt is only set to form encoded for POST.\r\n```\r\n\r\n\r\n### Error details\r\n\r\n```console\r\nNo errors.\r\n```\r\n\r\n\r\n### Environment data\r\n\r\n```powershell\r\nName Value\r\n---- -----\r\nPSVersion 7.2.0-rc.1\r\nPSEdition Core\r\nGitCommitId 7.2.0-rc.1\r\nOS Microsoft Windows 10.0.22000\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```\r\n\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/adamdriscoll","@type":"Person","name":"adamdriscoll"},"datePublished":"2021-10-27T20:39:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/16318/PowerShell/issues/16318"}
| 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:e57e3ff8-a0dd-75f9-7f65-eeb20fffe538 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9266:69FA9:EB9917:13F86F6:6A5565BC |
| html-safe-nonce | b2ff90c6eb6ea036d9708257f38e743185d12d251a7aea97317e23c4c4f10904 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjY2OjY5RkE5OkVCOTkxNzoxM0Y4NkY2OjZBNTU2NUJDIiwidmlzaXRvcl9pZCI6IjY2MjMyNTYzOTQ0OTcwOTEwMDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fdd4cd8a5f4319508cc211450507b22bedabadd4a44b076f505019ecf25665f7 |
| hovercard-subject-tag | issue:1037842437 |
| 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/16318/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bdc9b2b381f8d4213816985c445775717b7e4530ec98f44a4b182ee52161cb40/PowerShell/PowerShell/issues/16318 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bdc9b2b381f8d4213816985c445775717b7e4530ec98f44a4b182ee52161cb40/PowerShell/PowerShell/issues/16318 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | adamdriscoll |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| 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 | 8201d0b7bc32164c4662de52242e463a356df543 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width