diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Invoke-RestMethod.md b/reference/5.1/Microsoft.PowerShell.Utility/Invoke-RestMethod.md index e84f1d73d13d..1897c96d33f6 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Invoke-RestMethod.md +++ b/reference/5.1/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/03/2024 +ms.date: 02/05/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: Invoke-RestMethod @@ -252,9 +252,21 @@ Accept wildcard characters: False Specifies the content type of the web request. -If this parameter is omitted and the request method is POST, `Invoke-RestMethod` sets the content -type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in the -call. +If the value for **ContentType** contains the encoding format (as `charset`), the cmdlet uses that +format to encode the body of the web request. If the **ContentType** doesn't specify an encoding +format, the default encoding format is used instead. An example of a **ContentType** with an +encoding format is `text/plain; charset=iso-8859-5`, which specifies the +[Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet. + +If you omit the parameter, the content type may be different based on the HTTP method you use: + +- For a POST method, the content type is `application/x-www-form-urlencoded` +- For a PUT method, the content type is `application/json` +- For other methods, the content type isn't specified in the request + +If you are using the **InFile** parameter to upload a file, you should set the content type. +Usually, the type should be `application/octet-stream`. However, you need to set the content type +based on the requirements of the endpoint. ```yaml Type: System.String @@ -332,9 +344,12 @@ Accept wildcard characters: False ### -InFile -Gets the content of the web request from a file. +Gets the content of the web request body from a file. Enter a path and filename. If you omit the +path, the default is the current location. -Enter a path and file name. If you omit the path, the default is the current location. +You also need to set the content type of the request. For example, to upload a file you should set +the content type. Usually, the type should be `application/octet-stream`. However, you need to set +the content type based on the requirements of the endpoint. ```yaml Type: System.String diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Invoke-WebRequest.md b/reference/5.1/Microsoft.PowerShell.Utility/Invoke-WebRequest.md index 6cf00ffefdf5..53451f7e9a0c 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Invoke-WebRequest.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Invoke-WebRequest.md @@ -285,9 +285,21 @@ Accept wildcard characters: False Specifies the content type of the web request. -If this parameter is omitted and the request method is POST, `Invoke-WebRequest` sets the content -type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in the -call. +If the value for **ContentType** contains the encoding format (as `charset`), the cmdlet uses that +format to encode the body of the web request. If the **ContentType** doesn't specify an encoding +format, the default encoding format is used instead. An example of a **ContentType** with an +encoding format is `text/plain; charset=iso-8859-5`, which specifies the +[Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet. + +If you omit the parameter, the content type may be different based on the HTTP method you use: + +- For a POST method, the content type is `application/x-www-form-urlencoded` +- For a PUT method, the content type is `application/json` +- For other methods, the content type isn't specified in the request + +If you are using the **InFile** parameter to upload a file, you should set the content type. +Usually, the type should be `application/octet-stream`. However, you need to set the content type +based on the requirements of the endpoint. ```yaml Type: System.String @@ -366,9 +378,12 @@ Accept wildcard characters: False ### -InFile -Gets the content of the web request from a file. +Gets the content of the web request body from a file. Enter a path and filename. If you omit the +path, the default is the current location. -Enter a path and file name. If you omit the path, the default is the current location. +You also need to set the content type of the request. For example, to upload a file you should set +the content type. Usually, the type should be `application/octet-stream`. However, you need to set +the content type based on the requirements of the endpoint. ```yaml Type: System.String diff --git a/reference/7.4/Microsoft.PowerShell.Utility/Invoke-RestMethod.md b/reference/7.4/Microsoft.PowerShell.Utility/Invoke-RestMethod.md index ec6eab009030..f2283db73065 100644 --- a/reference/7.4/Microsoft.PowerShell.Utility/Invoke-RestMethod.md +++ b/reference/7.4/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/30/2025 +ms.date: 02/05/2025 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 @@ -526,11 +526,18 @@ format, the default encoding format is used instead. An example of a **ContentTy encoding format is `text/plain; charset=iso-8859-5`, which specifies the [Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet. -If this parameter is omitted and the request method is POST, `Invoke-RestMethod` sets the content -type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in the -call. +If you omit the parameter, the content type may be different based on the HTTP method you use: -**ContentType** is overridden when a `MultipartFormDataContent` object is supplied for **Body**. +- For a POST method, the content type is `application/x-www-form-urlencoded` +- For a PUT method, the content type is `application/json` +- For other methods, the content type isn't specified in the request + +If you are using the **InFile** parameter to upload a file, you should set the content type. +Usually, the type should be `application/octet-stream`. However, you need to set the content type +based on the requirements of the endpoint. + +**ContentType** is overridden when the **Body** is a +[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object. Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to define the `Content-Type` header, the value specified in the **ContentType** parameter is used. @@ -742,9 +749,12 @@ Accept wildcard characters: False ### -InFile -Gets the content of the web request from a file. +Gets the content of the web request body from a file. Enter a path and filename. If you omit the +path, the default is the current location. -Enter a path and file name. If you omit the path, the default is the current location. +You also need to set the content type of the request. For example, to upload a file you should set +the content type. Usually, the type should be `application/octet-stream`. However, you need to set +the content type based on the requirements of the endpoint. ```yaml Type: System.String diff --git a/reference/7.4/Microsoft.PowerShell.Utility/Invoke-WebRequest.md b/reference/7.4/Microsoft.PowerShell.Utility/Invoke-WebRequest.md index 9328fc28da75..a2652a7bc953 100644 --- a/reference/7.4/Microsoft.PowerShell.Utility/Invoke-WebRequest.md +++ b/reference/7.4/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: 11/18/2024 +ms.date: 02/05/2025 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 @@ -604,11 +604,18 @@ format, the default encoding format is used instead. An example of a **ContentTy encoding format is `text/plain; charset=iso-8859-5`, which specifies the [Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet. -If this parameter is omitted and the request method is POST or PUT, `Invoke-WebRequest` sets the -content type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in -the call. +If you omit the parameter, the content type may be different based on the HTTP method you use: -**ContentType** is overridden when a **MultipartFormDataContent** object is supplied for **Body**. +- For a POST method, the content type is `application/x-www-form-urlencoded` +- For a PUT method, the content type is `application/json` +- For other methods, the content type isn't specified in the request + +If you are using the **InFile** parameter to upload a file, you should set the content type. +Usually, the type should be `application/octet-stream`. However, you need to set the content type +based on the requirements of the endpoint. + +**ContentType** is overridden when the **Body** is a +[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object. Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to define the `Content-Type` header, the value specified in the **ContentType** parameter is used. @@ -793,8 +800,12 @@ Accept wildcard characters: False ### -InFile -Gets the content of the web request from a file. Enter a path and filename. If you omit the path, -the default is the current location. +Gets the content of the web request body from a file. Enter a path and filename. If you omit the +path, the default is the current location. + +You also need to set the content type of the request. For example, to upload a file you should set +the content type. Usually, the type should be `application/octet-stream`. However, you need to set +the content type based on the requirements of the endpoint. ```yaml Type: System.String diff --git a/reference/7.5/Microsoft.PowerShell.Utility/Invoke-RestMethod.md b/reference/7.5/Microsoft.PowerShell.Utility/Invoke-RestMethod.md index 6eb9ca1cf9d3..c5cecfa88daf 100644 --- a/reference/7.5/Microsoft.PowerShell.Utility/Invoke-RestMethod.md +++ b/reference/7.5/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/30/2025 +ms.date: 02/05/2025 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 @@ -526,11 +526,18 @@ format, the default encoding format is used instead. An example of a **ContentTy encoding format is `text/plain; charset=iso-8859-5`, which specifies the [Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet. -If this parameter is omitted and the request method is POST, `Invoke-RestMethod` sets the content -type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in the -call. +If you omit the parameter, the content type may be different based on the HTTP method you use: -**ContentType** is overridden when a `MultipartFormDataContent` object is supplied for **Body**. +- For a POST method, the content type is `application/x-www-form-urlencoded` +- For a PUT method, the content type is `application/json` +- For other methods, the content type isn't specified in the request + +If you are using the **InFile** parameter to upload a file, you should set the content type. +Usually, the type should be `application/octet-stream`. However, you need to set the content type +based on the requirements of the endpoint. + +**ContentType** is overridden when the **Body** is a +[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object. Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to define the `Content-Type` header, the value specified in the **ContentType** parameter is used. @@ -742,9 +749,12 @@ Accept wildcard characters: False ### -InFile -Gets the content of the web request from a file. +Gets the content of the web request body from a file. Enter a path and filename. If you omit the +path, the default is the current location. -Enter a path and file name. If you omit the path, the default is the current location. +You also need to set the content type of the request. For example, to upload a file you should set +the content type. Usually, the type should be `application/octet-stream`. However, you need to set +the content type based on the requirements of the endpoint. ```yaml Type: System.String diff --git a/reference/7.5/Microsoft.PowerShell.Utility/Invoke-WebRequest.md b/reference/7.5/Microsoft.PowerShell.Utility/Invoke-WebRequest.md index ed77d11e29bd..2051a34c8ec6 100644 --- a/reference/7.5/Microsoft.PowerShell.Utility/Invoke-WebRequest.md +++ b/reference/7.5/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: 11/18/2024 +ms.date: 02/05/2025 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 @@ -604,11 +604,18 @@ format, the default encoding format is used instead. An example of a **ContentTy encoding format is `text/plain; charset=iso-8859-5`, which specifies the [Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet. -If this parameter is omitted and the request method is POST or PUT, `Invoke-WebRequest` sets the -content type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in -the call. +If you omit the parameter, the content type may be different based on the HTTP method you use: -**ContentType** is overridden when a **MultipartFormDataContent** object is supplied for **Body**. +- For a POST method, the content type is `application/x-www-form-urlencoded` +- For a PUT method, the content type is `application/json` +- For other methods, the content type isn't specified in the request + +If you are using the **InFile** parameter to upload a file, you should set the content type. +Usually, the type should be `application/octet-stream`. However, you need to set the content type +based on the requirements of the endpoint. + +**ContentType** is overridden when the **Body** is a +[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object. Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to define the `Content-Type` header, the value specified in the **ContentType** parameter is used. @@ -793,8 +800,12 @@ Accept wildcard characters: False ### -InFile -Gets the content of the web request from a file. Enter a path and filename. If you omit the path, -the default is the current location. +Gets the content of the web request body from a file. Enter a path and filename. If you omit the +path, the default is the current location. + +You also need to set the content type of the request. For example, to upload a file you should set +the content type. Usually, the type should be `application/octet-stream`. However, you need to set +the content type based on the requirements of the endpoint. ```yaml Type: System.String diff --git a/reference/7.6/Microsoft.PowerShell.Utility/Invoke-RestMethod.md b/reference/7.6/Microsoft.PowerShell.Utility/Invoke-RestMethod.md index 5949adf58149..257dd77b3900 100644 --- a/reference/7.6/Microsoft.PowerShell.Utility/Invoke-RestMethod.md +++ b/reference/7.6/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/30/2025 +ms.date: 02/05/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.6&WT.mc_id=ps-gethelp schema: 2.0.0 title: Invoke-RestMethod @@ -526,11 +526,18 @@ format, the default encoding format is used instead. An example of a **ContentTy encoding format is `text/plain; charset=iso-8859-5`, which specifies the [Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet. -If this parameter is omitted and the request method is POST, `Invoke-RestMethod` sets the content -type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in the -call. +If you omit the parameter, the content type may be different based on the HTTP method you use: -**ContentType** is overridden when a `MultipartFormDataContent` object is supplied for **Body**. +- For a POST method, the content type is `application/x-www-form-urlencoded` +- For a PUT method, the content type is `application/json` +- For other methods, the content type isn't specified in the request + +If you are using the **InFile** parameter to upload a file, you should set the content type. +Usually, the type should be `application/octet-stream`. However, you need to set the content type +based on the requirements of the endpoint. + +**ContentType** is overridden when the **Body** is a +[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object. Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to define the `Content-Type` header, the value specified in the **ContentType** parameter is used. @@ -742,9 +749,12 @@ Accept wildcard characters: False ### -InFile -Gets the content of the web request from a file. +Gets the content of the web request body from a file. Enter a path and filename. If you omit the +path, the default is the current location. -Enter a path and file name. If you omit the path, the default is the current location. +You also need to set the content type of the request. For example, to upload a file you should set +the content type. Usually, the type should be `application/octet-stream`. However, you need to set +the content type based on the requirements of the endpoint. ```yaml Type: System.String diff --git a/reference/7.6/Microsoft.PowerShell.Utility/Invoke-WebRequest.md b/reference/7.6/Microsoft.PowerShell.Utility/Invoke-WebRequest.md index 3e73aab3c1b5..a48c64140101 100644 --- a/reference/7.6/Microsoft.PowerShell.Utility/Invoke-WebRequest.md +++ b/reference/7.6/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: 11/18/2024 +ms.date: 02/05/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.6&WT.mc_id=ps-gethelp schema: 2.0.0 title: Invoke-WebRequest @@ -604,11 +604,18 @@ format, the default encoding format is used instead. An example of a **ContentTy encoding format is `text/plain; charset=iso-8859-5`, which specifies the [Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet. -If this parameter is omitted and the request method is POST or PUT, `Invoke-WebRequest` sets the -content type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in -the call. +If you omit the parameter, the content type may be different based on the HTTP method you use: -**ContentType** is overridden when a **MultipartFormDataContent** object is supplied for **Body**. +- For a POST method, the content type is `application/x-www-form-urlencoded` +- For a PUT method, the content type is `application/json` +- For other methods, the content type isn't specified in the request + +If you are using the **InFile** parameter to upload a file, you should set the content type. +Usually, the type should be `application/octet-stream`. However, you need to set the content type +based on the requirements of the endpoint. + +**ContentType** is overridden when the **Body** is a +[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object. Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to define the `Content-Type` header, the value specified in the **ContentType** parameter is used. @@ -793,8 +800,12 @@ Accept wildcard characters: False ### -InFile -Gets the content of the web request from a file. Enter a path and filename. If you omit the path, -the default is the current location. +Gets the content of the web request body from a file. Enter a path and filename. If you omit the +path, the default is the current location. + +You also need to set the content type of the request. For example, to upload a file you should set +the content type. Usually, the type should be `application/octet-stream`. However, you need to set +the content type based on the requirements of the endpoint. ```yaml Type: System.String