Skip to content

Commit 75fdb77

Browse files
authored
Merge pull request #11775 from MicrosoftDocs/main
2/5/2025 PM Publish
2 parents b72863a + 0053fe1 commit 75fdb77

File tree

8 files changed

+146
-53
lines changed

8 files changed

+146
-53
lines changed

reference/5.1/Microsoft.PowerShell.Utility/Invoke-RestMethod.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Utility
5-
ms.date: 01/03/2024
5+
ms.date: 02/05/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-5.1&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Invoke-RestMethod
@@ -252,9 +252,21 @@ Accept wildcard characters: False
252252

253253
Specifies the content type of the web request.
254254

255-
If this parameter is omitted and the request method is POST, `Invoke-RestMethod` sets the content
256-
type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in the
257-
call.
255+
If the value for **ContentType** contains the encoding format (as `charset`), the cmdlet uses that
256+
format to encode the body of the web request. If the **ContentType** doesn't specify an encoding
257+
format, the default encoding format is used instead. An example of a **ContentType** with an
258+
encoding format is `text/plain; charset=iso-8859-5`, which specifies the
259+
[Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet.
260+
261+
If you omit the parameter, the content type may be different based on the HTTP method you use:
262+
263+
- For a POST method, the content type is `application/x-www-form-urlencoded`
264+
- For a PUT method, the content type is `application/json`
265+
- For other methods, the content type isn't specified in the request
266+
267+
If you are using the **InFile** parameter to upload a file, you should set the content type.
268+
Usually, the type should be `application/octet-stream`. However, you need to set the content type
269+
based on the requirements of the endpoint.
258270

259271
```yaml
260272
Type: System.String
@@ -332,9 +344,12 @@ Accept wildcard characters: False
332344

333345
### -InFile
334346

335-
Gets the content of the web request from a file.
347+
Gets the content of the web request body from a file. Enter a path and filename. If you omit the
348+
path, the default is the current location.
336349

337-
Enter a path and file name. If you omit the path, the default is the current location.
350+
You also need to set the content type of the request. For example, to upload a file you should set
351+
the content type. Usually, the type should be `application/octet-stream`. However, you need to set
352+
the content type based on the requirements of the endpoint.
338353

339354
```yaml
340355
Type: System.String

reference/5.1/Microsoft.PowerShell.Utility/Invoke-WebRequest.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,21 @@ Accept wildcard characters: False
285285

286286
Specifies the content type of the web request.
287287

288-
If this parameter is omitted and the request method is POST, `Invoke-WebRequest` sets the content
289-
type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in the
290-
call.
288+
If the value for **ContentType** contains the encoding format (as `charset`), the cmdlet uses that
289+
format to encode the body of the web request. If the **ContentType** doesn't specify an encoding
290+
format, the default encoding format is used instead. An example of a **ContentType** with an
291+
encoding format is `text/plain; charset=iso-8859-5`, which specifies the
292+
[Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet.
293+
294+
If you omit the parameter, the content type may be different based on the HTTP method you use:
295+
296+
- For a POST method, the content type is `application/x-www-form-urlencoded`
297+
- For a PUT method, the content type is `application/json`
298+
- For other methods, the content type isn't specified in the request
299+
300+
If you are using the **InFile** parameter to upload a file, you should set the content type.
301+
Usually, the type should be `application/octet-stream`. However, you need to set the content type
302+
based on the requirements of the endpoint.
291303

292304
```yaml
293305
Type: System.String
@@ -366,9 +378,12 @@ Accept wildcard characters: False
366378

367379
### -InFile
368380

369-
Gets the content of the web request from a file.
381+
Gets the content of the web request body from a file. Enter a path and filename. If you omit the
382+
path, the default is the current location.
370383

371-
Enter a path and file name. If you omit the path, the default is the current location.
384+
You also need to set the content type of the request. For example, to upload a file you should set
385+
the content type. Usually, the type should be `application/octet-stream`. However, you need to set
386+
the content type based on the requirements of the endpoint.
372387

373388
```yaml
374389
Type: System.String

reference/7.4/Microsoft.PowerShell.Utility/Invoke-RestMethod.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Utility
5-
ms.date: 01/30/2025
5+
ms.date: 02/05/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Invoke-RestMethod
@@ -526,11 +526,18 @@ format, the default encoding format is used instead. An example of a **ContentTy
526526
encoding format is `text/plain; charset=iso-8859-5`, which specifies the
527527
[Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet.
528528

529-
If this parameter is omitted and the request method is POST, `Invoke-RestMethod` sets the content
530-
type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in the
531-
call.
529+
If you omit the parameter, the content type may be different based on the HTTP method you use:
532530

533-
**ContentType** is overridden when a `MultipartFormDataContent` object is supplied for **Body**.
531+
- For a POST method, the content type is `application/x-www-form-urlencoded`
532+
- For a PUT method, the content type is `application/json`
533+
- For other methods, the content type isn't specified in the request
534+
535+
If you are using the **InFile** parameter to upload a file, you should set the content type.
536+
Usually, the type should be `application/octet-stream`. However, you need to set the content type
537+
based on the requirements of the endpoint.
538+
539+
**ContentType** is overridden when the **Body** is a
540+
[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object.
534541

535542
Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to
536543
define the `Content-Type` header, the value specified in the **ContentType** parameter is used.
@@ -742,9 +749,12 @@ Accept wildcard characters: False
742749

743750
### -InFile
744751

745-
Gets the content of the web request from a file.
752+
Gets the content of the web request body from a file. Enter a path and filename. If you omit the
753+
path, the default is the current location.
746754

747-
Enter a path and file name. If you omit the path, the default is the current location.
755+
You also need to set the content type of the request. For example, to upload a file you should set
756+
the content type. Usually, the type should be `application/octet-stream`. However, you need to set
757+
the content type based on the requirements of the endpoint.
748758

749759
```yaml
750760
Type: System.String

reference/7.4/Microsoft.PowerShell.Utility/Invoke-WebRequest.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Utility
5-
ms.date: 11/18/2024
5+
ms.date: 02/05/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Invoke-WebRequest
@@ -604,11 +604,18 @@ format, the default encoding format is used instead. An example of a **ContentTy
604604
encoding format is `text/plain; charset=iso-8859-5`, which specifies the
605605
[Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet.
606606

607-
If this parameter is omitted and the request method is POST or PUT, `Invoke-WebRequest` sets the
608-
content type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in
609-
the call.
607+
If you omit the parameter, the content type may be different based on the HTTP method you use:
610608

611-
**ContentType** is overridden when a **MultipartFormDataContent** object is supplied for **Body**.
609+
- For a POST method, the content type is `application/x-www-form-urlencoded`
610+
- For a PUT method, the content type is `application/json`
611+
- For other methods, the content type isn't specified in the request
612+
613+
If you are using the **InFile** parameter to upload a file, you should set the content type.
614+
Usually, the type should be `application/octet-stream`. However, you need to set the content type
615+
based on the requirements of the endpoint.
616+
617+
**ContentType** is overridden when the **Body** is a
618+
[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object.
612619

613620
Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to
614621
define the `Content-Type` header, the value specified in the **ContentType** parameter is used.
@@ -793,8 +800,12 @@ Accept wildcard characters: False
793800

794801
### -InFile
795802

796-
Gets the content of the web request from a file. Enter a path and filename. If you omit the path,
797-
the default is the current location.
803+
Gets the content of the web request body from a file. Enter a path and filename. If you omit the
804+
path, the default is the current location.
805+
806+
You also need to set the content type of the request. For example, to upload a file you should set
807+
the content type. Usually, the type should be `application/octet-stream`. However, you need to set
808+
the content type based on the requirements of the endpoint.
798809

799810
```yaml
800811
Type: System.String

reference/7.5/Microsoft.PowerShell.Utility/Invoke-RestMethod.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Utility
5-
ms.date: 01/30/2025
5+
ms.date: 02/05/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.5&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Invoke-RestMethod
@@ -526,11 +526,18 @@ format, the default encoding format is used instead. An example of a **ContentTy
526526
encoding format is `text/plain; charset=iso-8859-5`, which specifies the
527527
[Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet.
528528

529-
If this parameter is omitted and the request method is POST, `Invoke-RestMethod` sets the content
530-
type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in the
531-
call.
529+
If you omit the parameter, the content type may be different based on the HTTP method you use:
532530

533-
**ContentType** is overridden when a `MultipartFormDataContent` object is supplied for **Body**.
531+
- For a POST method, the content type is `application/x-www-form-urlencoded`
532+
- For a PUT method, the content type is `application/json`
533+
- For other methods, the content type isn't specified in the request
534+
535+
If you are using the **InFile** parameter to upload a file, you should set the content type.
536+
Usually, the type should be `application/octet-stream`. However, you need to set the content type
537+
based on the requirements of the endpoint.
538+
539+
**ContentType** is overridden when the **Body** is a
540+
[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object.
534541

535542
Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to
536543
define the `Content-Type` header, the value specified in the **ContentType** parameter is used.
@@ -742,9 +749,12 @@ Accept wildcard characters: False
742749

743750
### -InFile
744751

745-
Gets the content of the web request from a file.
752+
Gets the content of the web request body from a file. Enter a path and filename. If you omit the
753+
path, the default is the current location.
746754

747-
Enter a path and file name. If you omit the path, the default is the current location.
755+
You also need to set the content type of the request. For example, to upload a file you should set
756+
the content type. Usually, the type should be `application/octet-stream`. However, you need to set
757+
the content type based on the requirements of the endpoint.
748758

749759
```yaml
750760
Type: System.String

reference/7.5/Microsoft.PowerShell.Utility/Invoke-WebRequest.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Utility
5-
ms.date: 11/18/2024
5+
ms.date: 02/05/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.5&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Invoke-WebRequest
@@ -604,11 +604,18 @@ format, the default encoding format is used instead. An example of a **ContentTy
604604
encoding format is `text/plain; charset=iso-8859-5`, which specifies the
605605
[Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet.
606606

607-
If this parameter is omitted and the request method is POST or PUT, `Invoke-WebRequest` sets the
608-
content type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in
609-
the call.
607+
If you omit the parameter, the content type may be different based on the HTTP method you use:
610608

611-
**ContentType** is overridden when a **MultipartFormDataContent** object is supplied for **Body**.
609+
- For a POST method, the content type is `application/x-www-form-urlencoded`
610+
- For a PUT method, the content type is `application/json`
611+
- For other methods, the content type isn't specified in the request
612+
613+
If you are using the **InFile** parameter to upload a file, you should set the content type.
614+
Usually, the type should be `application/octet-stream`. However, you need to set the content type
615+
based on the requirements of the endpoint.
616+
617+
**ContentType** is overridden when the **Body** is a
618+
[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object.
612619

613620
Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to
614621
define the `Content-Type` header, the value specified in the **ContentType** parameter is used.
@@ -793,8 +800,12 @@ Accept wildcard characters: False
793800

794801
### -InFile
795802

796-
Gets the content of the web request from a file. Enter a path and filename. If you omit the path,
797-
the default is the current location.
803+
Gets the content of the web request body from a file. Enter a path and filename. If you omit the
804+
path, the default is the current location.
805+
806+
You also need to set the content type of the request. For example, to upload a file you should set
807+
the content type. Usually, the type should be `application/octet-stream`. However, you need to set
808+
the content type based on the requirements of the endpoint.
798809

799810
```yaml
800811
Type: System.String

reference/7.6/Microsoft.PowerShell.Utility/Invoke-RestMethod.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Utility
5-
ms.date: 01/30/2025
5+
ms.date: 02/05/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.6&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Invoke-RestMethod
@@ -526,11 +526,18 @@ format, the default encoding format is used instead. An example of a **ContentTy
526526
encoding format is `text/plain; charset=iso-8859-5`, which specifies the
527527
[Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet.
528528

529-
If this parameter is omitted and the request method is POST, `Invoke-RestMethod` sets the content
530-
type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in the
531-
call.
529+
If you omit the parameter, the content type may be different based on the HTTP method you use:
532530

533-
**ContentType** is overridden when a `MultipartFormDataContent` object is supplied for **Body**.
531+
- For a POST method, the content type is `application/x-www-form-urlencoded`
532+
- For a PUT method, the content type is `application/json`
533+
- For other methods, the content type isn't specified in the request
534+
535+
If you are using the **InFile** parameter to upload a file, you should set the content type.
536+
Usually, the type should be `application/octet-stream`. However, you need to set the content type
537+
based on the requirements of the endpoint.
538+
539+
**ContentType** is overridden when the **Body** is a
540+
[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object.
534541

535542
Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to
536543
define the `Content-Type` header, the value specified in the **ContentType** parameter is used.
@@ -742,9 +749,12 @@ Accept wildcard characters: False
742749

743750
### -InFile
744751

745-
Gets the content of the web request from a file.
752+
Gets the content of the web request body from a file. Enter a path and filename. If you omit the
753+
path, the default is the current location.
746754

747-
Enter a path and file name. If you omit the path, the default is the current location.
755+
You also need to set the content type of the request. For example, to upload a file you should set
756+
the content type. Usually, the type should be `application/octet-stream`. However, you need to set
757+
the content type based on the requirements of the endpoint.
748758

749759
```yaml
750760
Type: System.String

reference/7.6/Microsoft.PowerShell.Utility/Invoke-WebRequest.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Utility
5-
ms.date: 11/18/2024
5+
ms.date: 02/05/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.6&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Invoke-WebRequest
@@ -604,11 +604,18 @@ format, the default encoding format is used instead. An example of a **ContentTy
604604
encoding format is `text/plain; charset=iso-8859-5`, which specifies the
605605
[Latin/Cyrillic](https://www.iso.org/standard/28249.html) alphabet.
606606

607-
If this parameter is omitted and the request method is POST or PUT, `Invoke-WebRequest` sets the
608-
content type to `application/x-www-form-urlencoded`. Otherwise, the content type isn't specified in
609-
the call.
607+
If you omit the parameter, the content type may be different based on the HTTP method you use:
610608

611-
**ContentType** is overridden when a **MultipartFormDataContent** object is supplied for **Body**.
609+
- For a POST method, the content type is `application/x-www-form-urlencoded`
610+
- For a PUT method, the content type is `application/json`
611+
- For other methods, the content type isn't specified in the request
612+
613+
If you are using the **InFile** parameter to upload a file, you should set the content type.
614+
Usually, the type should be `application/octet-stream`. However, you need to set the content type
615+
based on the requirements of the endpoint.
616+
617+
**ContentType** is overridden when the **Body** is a
618+
[MultipartFormDataContent](xref:System.Net.Http.MultipartFormDataContent) object.
612619

613620
Starting in PowerShell 7.4, if you use this both this parameter and the **Headers** parameter to
614621
define the `Content-Type` header, the value specified in the **ContentType** parameter is used.
@@ -793,8 +800,12 @@ Accept wildcard characters: False
793800

794801
### -InFile
795802

796-
Gets the content of the web request from a file. Enter a path and filename. If you omit the path,
797-
the default is the current location.
803+
Gets the content of the web request body from a file. Enter a path and filename. If you omit the
804+
path, the default is the current location.
805+
806+
You also need to set the content type of the request. For example, to upload a file you should set
807+
the content type. Usually, the type should be `application/octet-stream`. However, you need to set
808+
the content type based on the requirements of the endpoint.
798809

799810
```yaml
800811
Type: System.String

0 commit comments

Comments
 (0)