Skip to content

Add QUERY method support for Invoke-WebRequest - #28110

Open
soroshsabz wants to merge 3 commits into
PowerShell:masterfrom
soroshsabz:features/1-query-method
Open

soroshsabz wants to merge 3 commits into
PowerShell:masterfrom
soroshsabz:features/1-query-method

Conversation

@soroshsabz

@soroshsabz soroshsabz commented Sep 25, 2026 •

Copy link
Copy Markdown

ITNOA

PR Summary

Add QUERY method support for Invoke-RestMethod or Invoke-WebRequest.

PR Context

This PR fixes #28061

PR Checklist

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@soroshsabz soroshsabz changed the title Add QUERY method support for Invoke-WebRequest WIP: Add QUERY method support for Invoke-WebRequest Sep 25, 2026
@soroshsabz soroshsabz changed the title WIP: Add QUERY method support for Invoke-WebRequest Add QUERY method support for Invoke-WebRequest Sep 25, 2026
@soroshsabz
soroshsabz marked this pull request as ready for review September 25, 2026 22:14
Copilot AI lite review requested due to automatic review settings September 25, 2026 22:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Implementation and test coverage are complete; only a minor documentation follow-up was noted.

Review effort: Lite
Findings: None

What changed in this PR

Adds first-class QUERY method support to PowerShell web cmdlets with integration tests.

Changes:

  • Adds WebRequestMethod.Query.
  • Maps it to .NET HttpMethod.Query.
  • Adds WebListener routes and cmdlet tests.
File Description
test/​tools/​WebListener/​Startup.cs Adds a QUERY test route.
test/​powershell/​Modules/​Microsoft.PowerShell.Utility/​WebCmdlets.Tests.ps1 Tests QUERY behavior and request bodies.
src/​Microsoft.PowerShell.Commands.Utility/​commands/​utility/​WebCmdlet/​WebRequestMethod.cs Adds the Query enum value.
src/​Microsoft.PowerShell.Commands.Utility/​commands/​utility/​WebCmdlet/​Common/​WebRequestPSCmdlet.Common.cs Maps Query to HttpMethod.Query.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@daxian-dbw Dongbo Wang (daxian-dbw) added WG-Cmdlets general cmdlet issues CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log WG-NeedsReview Needs a review by the labeled Working Group labels Sep 28, 2026
@daxian-dbw

Copy link
Copy Markdown
Member

A note to Cmdlet WG for review: PowerShell already supports sending Query, just not through the enum-backed -Method parameter: Invoke-WebRequest -Uri $uri -CustomMethod QUERY -Body $body.

The enum-backed methods are a curated list of methods. It contains Merge, which is not exposed by a convenient property from System.Net.Http.HttpMethod. HttpMethod exposes 2 convenient properties Connect and Query that are not included in the PowerShell enum. The WG needs to consider if we want to include Connect and Query for -Method, or the existing -CustomMethod is sufficient for them.

@soroshsabz

Copy link
Copy Markdown
Author

Dongbo Wang (@daxian-dbw) what is workflow for review?

@kilasuit

Copy link
Copy Markdown
Collaborator

soroshsabz this PR is marked for the Cmdlets Group to review. Please wait for us to get back to you. Also we hadn't yet discussed the issue this PR is to resolve so we have not yet made a recommendation on how or if it needs fixed.

I suggest in future looking for issues that are labeled as up for grabs to implement as opposed to newer issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log WG-Cmdlets general cmdlet issues WG-NeedsReview Needs a review by the labeled Working Group

Projects

Status: Queue

Development

Successfully merging this pull request may close these issues.

Add support for WebRequestMethod QUERY

4 participants