Skip to content

Commit

Permalink
(GH-11155) Document body-to-query-param encoding (#11157)
Browse files Browse the repository at this point in the history
Prior to this change, the documentation didn't clearly indicate that the
converted key-value pairs for requests from the **Body** parameter were
URL encoded or point users to how those strings are encoded.

This change:

- Adds a brief note indicating that the cmdlet uses the `WebUtility.UrlEncode()`
  method and points to that method reference for more information about the
  encoding behavior.
- Resolves #11155
- Fixes AB#260889
  • Loading branch information
michaeltlombardi authored Jun 3, 2024
1 parent fe3bfa7 commit 3cec573
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 04/04/2024
ms.date: 06/03/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Invoke-RestMethod
Expand Down Expand Up @@ -352,7 +352,9 @@ Specifies the body of the request. The body is the content of the request that f
You can also pipe a body value to `Invoke-RestMethod`.

The **Body** parameter can be used to specify a list of query parameters or specify the content of
the response.
the response. For query parameters, the cmdlet uses the **System.Net.WebUtility.UrlEncode** method
method to encode the key-value pairs. For more information about encoding strings for URLs, see
[the UrlEncode() method reference](xref:System.Net.WebUtility.UrlEncode).

When the input is a POST request and the body is a **String**, the value to the left of the first
equals sign (`=`) is set as a key in the form data and the remaining text is set as the value. To
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 04/04/2024
ms.date: 06/03/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Invoke-WebRequest
Expand Down Expand Up @@ -435,7 +435,9 @@ Specifies the body of the request. The body is the content of the request that f
You can also pipe a body value to `Invoke-WebRequest`.

The **Body** parameter can be used to specify a list of query parameters or specify the content of
the response.
the response. For query parameters, the cmdlet uses the **System.Net.WebUtility.UrlEncode** method
method to encode the key-value pairs. For more information about encoding strings for URLs, see
[the UrlEncode() method reference](xref:System.Net.WebUtility.UrlEncode).

When the input is a POST request and the body is a **String**, the value to the left of the first
equals sign (`=`) is set as a key in the form data and the remaining text is set as the value. To
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 04/04/2024
ms.date: 06/03/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Invoke-RestMethod
Expand Down Expand Up @@ -406,7 +406,9 @@ Specifies the body of the request. The body is the content of the request that f
You can also pipe a body value to `Invoke-RestMethod`.

The **Body** parameter can be used to specify a list of query parameters or specify the content of
the response.
the response. For query parameters, the cmdlet uses the **System.Net.WebUtility.UrlEncode** method
method to encode the key-value pairs. For more information about encoding strings for URLs, see
[the UrlEncode() method reference](xref:System.Net.WebUtility.UrlEncode).

When the input is a POST request and the body is a **String**, the value to the left of the first
equals sign (`=`) is set as a key in the form data and the remaining text is set as the value. To
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 04/04/2024
ms.date: 06/03/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Invoke-WebRequest
Expand Down Expand Up @@ -487,7 +487,9 @@ Specifies the body of the request. The body is the content of the request that f
You can also pipe a body value to `Invoke-WebRequest`.

The **Body** parameter can be used to specify a list of query parameters or specify the content of
the response.
the response. For query parameters, the cmdlet uses the **System.Net.WebUtility.UrlEncode** method
method to encode the key-value pairs. For more information about encoding strings for URLs, see
[the UrlEncode() method reference](xref:System.Net.WebUtility.UrlEncode).

When the input is a POST request and the body is a **String**, the value to the left of the first
equals sign (`=`) is set as a key in the form data and the remaining text is set as the value. To
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 04/04/2024
ms.date: 06/03/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.5&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Invoke-RestMethod
Expand Down Expand Up @@ -406,7 +406,9 @@ Specifies the body of the request. The body is the content of the request that f
You can also pipe a body value to `Invoke-RestMethod`.

The **Body** parameter can be used to specify a list of query parameters or specify the content of
the response.
the response. For query parameters, the cmdlet uses the **System.Net.WebUtility.UrlEncode** method
method to encode the key-value pairs. For more information about encoding strings for URLs, see
[the UrlEncode() method reference](xref:System.Net.WebUtility.UrlEncode).

When the input is a POST request and the body is a **String**, the value to the left of the first
equals sign (`=`) is set as a key in the form data and the remaining text is set as the value. To
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 04/04/2024
ms.date: 06/03/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.5&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Invoke-WebRequest
Expand Down Expand Up @@ -487,7 +487,9 @@ Specifies the body of the request. The body is the content of the request that f
You can also pipe a body value to `Invoke-WebRequest`.

The **Body** parameter can be used to specify a list of query parameters or specify the content of
the response.
the response. For query parameters, the cmdlet uses the **System.Net.WebUtility.UrlEncode** method
method to encode the key-value pairs. For more information about encoding strings for URLs, see
[the UrlEncode() method reference](xref:System.Net.WebUtility.UrlEncode).

When the input is a POST request and the body is a **String**, the value to the left of the first
equals sign (`=`) is set as a key in the form data and the remaining text is set as the value. To
Expand Down

0 comments on commit 3cec573

Please sign in to comment.