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

Invoke-RestMethod doesn't include automatic ContentType value when not using POST method #16318

Open
5 tasks done
adamdriscoll opened this issue Oct 27, 2021 · 0 comments
Open
5 tasks done

Comments

@adamdriscoll
Copy link
Contributor

@adamdriscoll adamdriscoll commented Oct 27, 2021

Prerequisites

Steps to reproduce

When using a POST, ContentType is automatically set to application/x-www-form-urlencoded

 invoke-restmethod https://webhook.site/6a5097af-3644-4462-9d92-d910088d2f4d -Method POST -Body @{ Test = "test" }

When using other methods, it is not. It is blank.

 invoke-restmethod https://webhook.site/6a5097af-3644-4462-9d92-d910088d2f4d -Method PUT -Body @{ Test = "test" }

image

Expected behavior

I would expect that the content type would default to form encoded for all request methods (or at least for PUT). 

Actual behavior

It is only set to form encoded for POST.

Error details

No errors.

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.0-rc.1
PSEdition                      Core
GitCommitId                    7.2.0-rc.1
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


### Visuals

_No response_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant