From 7a00f8260c18adbd212acb938ac44c7dea5888ed Mon Sep 17 00:00:00 2001 From: Seyyed Soroosh Hosseinalipour Date: Sat, 26 Sep 2026 02:13:59 +0330 Subject: [PATCH 1/3] Document the new Query value for the -Method parameter of Invoke-WebRequest and Invoke-RestMethod --- .../Invoke-RestMethod.md | 30 +++++++++++++++++-- .../Invoke-WebRequest.md | 30 +++++++++++++++++-- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md index ed9b78982936..b7193583bdb8 100644 --- a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md +++ b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 01/20/2026 +ms.date: 09/26/2026 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.7&WT.mc_id=ps-gethelp schema: 2.0.0 aliases: @@ -337,6 +337,19 @@ Unix socket. Invoke-RestMethod -Uri http://localhost/v1.40/images/json -UnixSocket '/var/run/docker.sock' ``` +### Example 10: Send a search request using the HTTP QUERY method + +This example sends a search request using the HTTP QUERY method. The QUERY method is safe and +idempotent like GET, but it carries the query parameters in the request body instead of the URI. +Because the `Query` method isn't given a default content-type, the example explicitly sets the +**ContentType** parameter. + +```powershell +$uri = 'https://api.contoso.com/search' +Invoke-RestMethod -Uri $uri -Method Query -Body @{ term = 'powershell'; limit = 10 } ` + -ContentType 'application/x-www-form-urlencoded' +``` + ## PARAMETERS ### -AllowInsecureRedirect @@ -854,16 +867,23 @@ Specifies the method used for the web request. The acceptable values for this pa - `Options` - `Patch` - `Post` +- `Query` - `Put` - `Trace` +The `Query` value specifies the HTTP QUERY method. The QUERY method is safe and idempotent like +`Get`, but it sends the query parameters in the request body instead of the URI. This is useful for +search or filter requests that exceed URI length limits or that pass structured data. When `-Body` +is a hashtable, it's sent as the request content rather than being converted into URI query +parameters. + The **CustomMethod** parameter can be used for Request Methods not listed above. ```yaml Type: Microsoft.PowerShell.Commands.WebRequestMethod Parameter Sets: StandardMethod, StandardMethodNoProxy Aliases: -Accepted values: Default, Get, Head, Post, Put, Delete, Trace, Options, Merge, Patch +Accepted values: Default, Get, Head, Post, Put, Delete, Trace, Options, Merge, Patch, Query Required: False Position: Named @@ -1543,6 +1563,12 @@ are: PowerShell 7.4 added support for the Brotli compression algorithm. +PowerShell 7.7 added the `Query` value for the **Method** parameter, which specifies the HTTP QUERY +method. Unlike `Post`, requests that use the `Query` method aren't given a default +`application/x-www-form-urlencoded` content-type. Use the **ContentType** parameter to specify the +content-type explicitly. If a `Query` request receives a `303 (See Other)` redirect response, the +request is resent using the `Get` method. + ## RELATED LINKS [ConvertTo-Json](ConvertTo-Json.md) diff --git a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md index fd6831e09c36..4948fa526778 100644 --- a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md +++ b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 01/20/2026 +ms.date: 09/26/2026 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.7&WT.mc_id=ps-gethelp schema: 2.0.0 aliases: @@ -418,6 +418,19 @@ Unix socket. Invoke-WebRequest -Uri http://localhost/v1.40/images/json -UnixSocket '/var/run/docker.sock' ``` +### Example 12: Send a search request using the HTTP QUERY method + +This example sends a search request using the HTTP QUERY method. The QUERY method is safe and +idempotent like GET, but it carries the query parameters in the request body instead of the URI. +Because the `Query` method isn't given a default content-type, the example explicitly sets the +**ContentType** parameter. + +```powershell +$uri = 'https://api.contoso.com/search' +Invoke-WebRequest -Uri $uri -Method Query -Body @{ term = 'powershell'; limit = 10 } ` + -ContentType 'application/x-www-form-urlencoded' +``` + ## PARAMETERS ### -AllowInsecureRedirect @@ -887,16 +900,23 @@ Specifies the method used for the web request. The acceptable values for this pa - `Options` - `Patch` - `Post` +- `Query` - `Put` - `Trace` +The `Query` value specifies the HTTP QUERY method. The QUERY method is safe and idempotent like +`Get`, but it sends the query parameters in the request body instead of the URI. This is useful for +search or filter requests that exceed URI length limits or that pass structured data. When `-Body` +is a hashtable, it's sent as the request content rather than being converted into URI query +parameters. + The **CustomMethod** parameter can be used for Request Methods not listed above. ```yaml Type: Microsoft.PowerShell.Commands.WebRequestMethod Parameter Sets: StandardMethod, StandardMethodNoProxy Aliases: -Accepted values: Default, Get, Head, Post, Put, Delete, Trace, Options, Merge, Patch +Accepted values: Default, Get, Head, Post, Put, Delete, Trace, Options, Merge, Patch, Query Required: False Position: Named @@ -1535,6 +1555,12 @@ are: PowerShell 7.4 added support for the Brotli compression algorithm. +PowerShell 7.7 added the `Query` value for the **Method** parameter, which specifies the HTTP QUERY +method. Unlike `Post`, requests that use the `Query` method aren't given a default +`application/x-www-form-urlencoded` content-type. Use the **ContentType** parameter to specify the +content-type explicitly. If a `Query` request receives a `303 (See Other)` redirect response, the +request is resent using the `Get` method. + ## RELATED LINKS [Invoke-RestMethod](Invoke-RestMethod.md) From 0d59f1683bfa40d3ca74e1b85f78040f8b2254e9 Mon Sep 17 00:00:00 2001 From: Seyyed Soroosh Hosseinalipour Date: Sat, 26 Sep 2026 02:28:43 +0330 Subject: [PATCH 2/3] Remove some extra sentences --- .../Invoke-RestMethod.md | 30 +++++++++++-------- .../Invoke-WebRequest.md | 30 +++++++++++-------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md index b7193583bdb8..ea218e3b33bb 100644 --- a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md +++ b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md @@ -345,9 +345,13 @@ Because the `Query` method isn't given a default content-type, the example expli **ContentType** parameter. ```powershell -$uri = 'https://api.contoso.com/search' -Invoke-RestMethod -Uri $uri -Method Query -Body @{ term = 'powershell'; limit = 10 } ` - -ContentType 'application/x-www-form-urlencoded' +$parameters = @{ + Uri = 'https://api.contoso.com/search' + Method = 'Query' + Body = @{ term = 'powershell'; limit = 10 } + ContentType = 'application/x-www-form-urlencoded' +} +Invoke-RestMethod @parameters ``` ## PARAMETERS @@ -872,10 +876,16 @@ Specifies the method used for the web request. The acceptable values for this pa - `Trace` The `Query` value specifies the HTTP QUERY method. The QUERY method is safe and idempotent like -`Get`, but it sends the query parameters in the request body instead of the URI. This is useful for -search or filter requests that exceed URI length limits or that pass structured data. When `-Body` -is a hashtable, it's sent as the request content rather than being converted into URI query -parameters. +`Get`, but it sends the query parameters in the request body instead of the URI. This is useful +for search or filter requests that exceed URI length limits or that pass structured data. When +the value of the **Body** parameter is a hashtable, it's sent as the request content rather than +being converted into URI query parameters. + +Unlike `Post`, requests that use the `Query` method aren't given a default +`application/x-www-form-urlencoded` content-type. Use the **ContentType** parameter to specify +the content-type explicitly. + +This value was introduced in PowerShell 7.7. The **CustomMethod** parameter can be used for Request Methods not listed above. @@ -1563,12 +1573,6 @@ are: PowerShell 7.4 added support for the Brotli compression algorithm. -PowerShell 7.7 added the `Query` value for the **Method** parameter, which specifies the HTTP QUERY -method. Unlike `Post`, requests that use the `Query` method aren't given a default -`application/x-www-form-urlencoded` content-type. Use the **ContentType** parameter to specify the -content-type explicitly. If a `Query` request receives a `303 (See Other)` redirect response, the -request is resent using the `Get` method. - ## RELATED LINKS [ConvertTo-Json](ConvertTo-Json.md) diff --git a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md index 4948fa526778..ad25590bfca0 100644 --- a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md +++ b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md @@ -426,9 +426,13 @@ Because the `Query` method isn't given a default content-type, the example expli **ContentType** parameter. ```powershell -$uri = 'https://api.contoso.com/search' -Invoke-WebRequest -Uri $uri -Method Query -Body @{ term = 'powershell'; limit = 10 } ` - -ContentType 'application/x-www-form-urlencoded' +$parameters = @{ + Uri = 'https://api.contoso.com/search' + Method = 'Query' + Body = @{ term = 'powershell'; limit = 10 } + ContentType = 'application/x-www-form-urlencoded' +} +Invoke-WebRequest @parameters ``` ## PARAMETERS @@ -905,10 +909,16 @@ Specifies the method used for the web request. The acceptable values for this pa - `Trace` The `Query` value specifies the HTTP QUERY method. The QUERY method is safe and idempotent like -`Get`, but it sends the query parameters in the request body instead of the URI. This is useful for -search or filter requests that exceed URI length limits or that pass structured data. When `-Body` -is a hashtable, it's sent as the request content rather than being converted into URI query -parameters. +`Get`, but it sends the query parameters in the request body instead of the URI. This is useful +for search or filter requests that exceed URI length limits or that pass structured data. When +the value of the **Body** parameter is a hashtable, it's sent as the request content rather than +being converted into URI query parameters. + +Unlike `Post`, requests that use the `Query` method aren't given a default +`application/x-www-form-urlencoded` content-type. Use the **ContentType** parameter to specify +the content-type explicitly. + +This value was introduced in PowerShell 7.7. The **CustomMethod** parameter can be used for Request Methods not listed above. @@ -1555,12 +1565,6 @@ are: PowerShell 7.4 added support for the Brotli compression algorithm. -PowerShell 7.7 added the `Query` value for the **Method** parameter, which specifies the HTTP QUERY -method. Unlike `Post`, requests that use the `Query` method aren't given a default -`application/x-www-form-urlencoded` content-type. Use the **ContentType** parameter to specify the -content-type explicitly. If a `Query` request receives a `303 (See Other)` redirect response, the -request is resent using the `Get` method. - ## RELATED LINKS [Invoke-RestMethod](Invoke-RestMethod.md) From 44cdb467f3ab575996e511c0538c6259f44d497b Mon Sep 17 00:00:00 2001 From: Seyyed Soroosh Hosseinalipour Date: Sat, 26 Sep 2026 02:42:39 +0330 Subject: [PATCH 3/3] Make example normal form --- .../Invoke-RestMethod.md | 24 +++++-------------- .../Invoke-WebRequest.md | 24 +++++-------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md index ea218e3b33bb..03f9ff3874ae 100644 --- a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md +++ b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-RestMethod.md @@ -345,13 +345,10 @@ Because the `Query` method isn't given a default content-type, the example expli **ContentType** parameter. ```powershell -$parameters = @{ - Uri = 'https://api.contoso.com/search' - Method = 'Query' - Body = @{ term = 'powershell'; limit = 10 } - ContentType = 'application/x-www-form-urlencoded' -} -Invoke-RestMethod @parameters +$uri = 'https://api.contoso.com/search' +$body = @{ term = 'powershell'; limit = 10 } +$contentType = 'application/x-www-form-urlencoded' +Invoke-RestMethod -Uri $uri -Method Query -Body $body -ContentType $contentType ``` ## PARAMETERS @@ -875,17 +872,8 @@ Specifies the method used for the web request. The acceptable values for this pa - `Put` - `Trace` -The `Query` value specifies the HTTP QUERY method. The QUERY method is safe and idempotent like -`Get`, but it sends the query parameters in the request body instead of the URI. This is useful -for search or filter requests that exceed URI length limits or that pass structured data. When -the value of the **Body** parameter is a hashtable, it's sent as the request content rather than -being converted into URI query parameters. - -Unlike `Post`, requests that use the `Query` method aren't given a default -`application/x-www-form-urlencoded` content-type. Use the **ContentType** parameter to specify -the content-type explicitly. - -This value was introduced in PowerShell 7.7. +> [!NOTE] +> The `Query` value was added in PowerShell 7.7. The **CustomMethod** parameter can be used for Request Methods not listed above. diff --git a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md index ad25590bfca0..ecac68426927 100644 --- a/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md +++ b/reference/7.7/Microsoft.PowerShell.Utility/Invoke-WebRequest.md @@ -426,13 +426,10 @@ Because the `Query` method isn't given a default content-type, the example expli **ContentType** parameter. ```powershell -$parameters = @{ - Uri = 'https://api.contoso.com/search' - Method = 'Query' - Body = @{ term = 'powershell'; limit = 10 } - ContentType = 'application/x-www-form-urlencoded' -} -Invoke-WebRequest @parameters +$uri = 'https://api.contoso.com/search' +$body = @{ term = 'powershell'; limit = 10 } +$contentType = 'application/x-www-form-urlencoded' +Invoke-WebRequest -Uri $uri -Method Query -Body $body -ContentType $contentType ``` ## PARAMETERS @@ -908,17 +905,8 @@ Specifies the method used for the web request. The acceptable values for this pa - `Put` - `Trace` -The `Query` value specifies the HTTP QUERY method. The QUERY method is safe and idempotent like -`Get`, but it sends the query parameters in the request body instead of the URI. This is useful -for search or filter requests that exceed URI length limits or that pass structured data. When -the value of the **Body** parameter is a hashtable, it's sent as the request content rather than -being converted into URI query parameters. - -Unlike `Post`, requests that use the `Query` method aren't given a default -`application/x-www-form-urlencoded` content-type. Use the **ContentType** parameter to specify -the content-type explicitly. - -This value was introduced in PowerShell 7.7. +> [!NOTE] +> The `Query` value was added in PowerShell 7.7. The **CustomMethod** parameter can be used for Request Methods not listed above.