Skip to content

Conversation

@CarloToso
Copy link
Contributor

@CarloToso CarloToso commented Jun 14, 2024

PR Summary

I reproduced the issue with every method except POST; now it should work correctly
In PS 7.4 and 7.4.1 PUT had the same behaviour as POST, so it worked without issues
Added some tests (checked with curl)

PR Context

Fixes #23827
@iSazonov

PR Checklist

@CarloToso CarloToso marked this pull request as draft June 14, 2024 02:43
@CarloToso CarloToso changed the title WebCmdlets fix issue with -Body and no -ContentType WIP: WebCmdlets fix issue with -Body and no -ContentType Jun 14, 2024
@iSazonov iSazonov added CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log PowerShell-Docs not needed The PR was reviewed and doesn't appear to require a PowerShell Docs update labels Jun 14, 2024
@CarloToso CarloToso changed the title WIP: WebCmdlets fix issue with -Body and no -ContentType WebCmdlets fix issue with -Body and no -ContentType Jun 15, 2024
@CarloToso CarloToso marked this pull request as ready for review June 15, 2024 14:20
@iSazonov
Copy link
Collaborator

@borland @bondido Could you please download compiled artifact from the PR and confirm that the issue is solved?

…s.Tests.ps1

Co-authored-by: Ilya <darpa@yandex.ru>
@borland
Copy link

borland commented Jun 16, 2024

@borland @bondido Could you please download compiled artifact from the PR and confirm that the issue is solved?

@iSazonov I'm not familiar with the CI setup here. I clicked through to Azure DevOps and found this:
https://dev.azure.com/powershell/PowerShell/_build/results?buildId=148781&view=artifacts&pathAsName=false&type=publishedArtifacts

I downloaded it, launched, and it said it was PowerShell 7.5.0-preview.4 so I assume that is the correct thing.

From there, I ran the exact same test. On PowerShell 7.4.2 (windows x64) I get

Invoke-RestMethod: The given key 'Content-Type' was not present in the dictionary.

I do not see any log entries on my local test server; PowerShell never sends the request.

On the 7.5.0-preview.4 pull request build, I do not get the error. The logs on my local server confirm that PowerShell is sending the request and the behaviour looks similar to older versions of PowerShell where this worked. Thank you!

For reference: My repro is fairly simple: I have a local aspnetcore webserver (but any HTTP API server will do) and I'm sending a JSON PUT as follows:

$header = @{}
$body = '{ }' // actual body content is specific to my webserver, but is irrelevant for the repro
Invoke-RestMethod -Method Put -Uri "<local server URI>" -Body $body -Headers $header

@iSazonov iSazonov requested a review from SteveL-MSFT June 16, 2024 19:16
@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Jun 25, 2024
@daxian-dbw daxian-dbw merged commit 86a7262 into PowerShell:master Jul 1, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Review - Needed The PR is being reviewed label Jul 1, 2024
@adityapatwardhan
Copy link
Member

We will wait for a preview release with this change before backporting to 7.4

@TravisEz13
Copy link
Member

@PowerShell/powershell-maintainers
Because this is a regression after 7.4 release, we believe this meets the bar for backport for 7.4

daxian-dbw pushed a commit to daxian-dbw/PowerShell that referenced this pull request Aug 13, 2024
daxian-dbw added a commit that referenced this pull request Aug 13, 2024
…3952) (#24145)

Co-authored-by: CarloToso <105941898+CarloToso@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BackPort-7.4.x-Done CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log PowerShell-Docs not needed The PR was reviewed and doesn't appear to require a PowerShell Docs update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invoke-WebRequest and Invoke-RestMethod in Powershell 7.4.2 - errors using PUT method

6 participants