Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 85 additions & 50 deletions reference/7.4/Microsoft.PowerShell.Utility/Invoke-RestMethod.md
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: 06/30/2023
ms.date: 08/18/2023
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 All @@ -18,74 +18,77 @@ Sends an HTTP or HTTPS request to a RESTful web service.
### StandardMethod (Default)

```
Invoke-RestMethod [-Uri] <uri> [-FollowRelLink] [-MaximumFollowRelLink <int>]
[-ResponseHeadersVariable <string>] [-StatusCodeVariable <string>] [-UseBasicParsing]
[-HttpVersion <version>] [-WebSession <WebRequestSession>] [-SessionVariable <string>]
Invoke-RestMethod [-FollowRelLink] [-MaximumFollowRelLink <Int32>]
[-ResponseHeadersVariable <String>] [-StatusCodeVariable <String>] [-UseBasicParsing] [-Uri] <Uri>
[-HttpVersion <Version>] [-WebSession <WebRequestSession>] [-SessionVariable <String>]
[-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>]
[-Credential <pscredential>] [-UseDefaultCredentials] [-CertificateThumbprint <string>]
[-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>]
[-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>]
[-Token <securestring>] [-UserAgent <string>] [-DisableKeepAlive]
[-ConnectionTimeoutSeconds <int>] [-OperationTimeoutSeconds <int>] [-Headers <IDictionary>]
[-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <int>]
[-MaximumRetryCount <int>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <int>]
[-Method <WebRequestMethod>] [-PreserveHttpMethodOnRedirect] [-Proxy <uri>]
[-ProxyCredential <pscredential>] [-ProxyUseDefaultCredentials] [-Body <Object>]
[-Form <IDictionary>] [-ContentType <string>] [-TransferEncoding <string>] [-InFile <string>]
[-OutFile <string>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [<CommonParameters>]
[-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive]
[-ConnectionTimeoutSeconds <Int32>] [-OperationTimeoutSeconds <Int32>] [-Headers <IDictionary>]
[-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <Int32>]
[-MaximumRetryCount <Int32>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <Int32>]
[-Method <WebRequestMethod>] [-PreserveHttpMethodOnRedirect]
[-UnixSocket <UnixDomainSocketEndPoint>] [-Proxy <Uri>] [-ProxyCredential <PSCredential>]
[-ProxyUseDefaultCredentials] [-Body <Object>] [-Form <IDictionary>] [-ContentType <String>]
[-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] [-PassThru] [-Resume]
[-SkipHttpErrorCheck] [<CommonParameters>]
```

### StandardMethodNoProxy

```
Invoke-RestMethod [-Uri] <uri> -NoProxy [-FollowRelLink] [-MaximumFollowRelLink <int>]
[-ResponseHeadersVariable <string>] [-StatusCodeVariable <string>] [-UseBasicParsing]
[-HttpVersion <version>] [-WebSession <WebRequestSession>] [-SessionVariable <string>]
Invoke-RestMethod [-FollowRelLink] [-MaximumFollowRelLink <Int32>]
[-ResponseHeadersVariable <String>] [-StatusCodeVariable <String>] [-UseBasicParsing] [-Uri] <Uri>
[-HttpVersion <Version>] [-WebSession <WebRequestSession>] [-SessionVariable <String>]
[-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>]
[-Credential <pscredential>] [-UseDefaultCredentials] [-CertificateThumbprint <string>]
[-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>]
[-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>]
[-Token <securestring>] [-UserAgent <string>] [-DisableKeepAlive]
[-ConnectionTimeoutSeconds <int>] [-OperationTimeoutSeconds <int>] [-Headers <IDictionary>]
[-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <int>]
[-MaximumRetryCount <int>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <int>]
[-Method <WebRequestMethod>] [-PreserveHttpMethodOnRedirect] [-Body <Object>]
[-Form <IDictionary>] [-ContentType <string>] [-TransferEncoding <string>] [-InFile <string>]
[-OutFile <string>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [<CommonParameters>]
[-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive]
[-ConnectionTimeoutSeconds <Int32>] [-OperationTimeoutSeconds <Int32>] [-Headers <IDictionary>]
[-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <Int32>]
[-MaximumRetryCount <Int32>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <Int32>]
[-Method <WebRequestMethod>] [-PreserveHttpMethodOnRedirect]
[-UnixSocket <UnixDomainSocketEndPoint>] [-NoProxy] [-Body <Object>] [-Form <IDictionary>]
[-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>]
[-PassThru] [-Resume] [-SkipHttpErrorCheck] [<CommonParameters>]
```

### CustomMethod

```
Invoke-RestMethod [-Uri] <uri> -CustomMethod <string> [-FollowRelLink]
[-MaximumFollowRelLink <int>] [-ResponseHeadersVariable <string>] [-StatusCodeVariable <string>]
[-UseBasicParsing] [-HttpVersion <version>] [-WebSession <WebRequestSession>]
[-SessionVariable <string>] [-AllowUnencryptedAuthentication]
[-Authentication <WebAuthenticationType>] [-Credential <pscredential>] [-UseDefaultCredentials]
[-CertificateThumbprint <string>] [-Certificate <X509Certificate>] [-SkipCertificateCheck]
[-SslProtocol <WebSslProtocol>] [-Token <securestring>] [-UserAgent <string>] [-DisableKeepAlive]
[-ConnectionTimeoutSeconds <int>] [-OperationTimeoutSeconds <int>] [-Headers <IDictionary>]
[-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <int>]
[-MaximumRetryCount <int>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <int>]
[-PreserveHttpMethodOnRedirect] [-Proxy <uri>] [-ProxyCredential <pscredential>]
[-ProxyUseDefaultCredentials] [-Body <Object>] [-Form <IDictionary>] [-ContentType <string>]
[-TransferEncoding <string>] [-InFile <string>] [-OutFile <string>] [-PassThru] [-Resume]
[-SkipHttpErrorCheck] [<CommonParameters>]
Invoke-RestMethod [-FollowRelLink] [-MaximumFollowRelLink <Int32>]
[-ResponseHeadersVariable <String>] [-StatusCodeVariable <String>] [-UseBasicParsing] [-Uri] <Uri>
[-HttpVersion <Version>] [-WebSession <WebRequestSession>] [-SessionVariable <String>]
[-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>]
[-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>]
[-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>]
[-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive]
[-ConnectionTimeoutSeconds <Int32>] [-OperationTimeoutSeconds <Int32>] [-Headers <IDictionary>]
[-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <Int32>]
[-MaximumRetryCount <Int32>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <Int32>]
-CustomMethod <String> [-PreserveHttpMethodOnRedirect] [-UnixSocket <UnixDomainSocketEndPoint>]
[-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials] [-Body <Object>]
[-Form <IDictionary>] [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>]
[-OutFile <String>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [<CommonParameters>]
```

### CustomMethodNoProxy

```
Invoke-RestMethod [-Uri] <uri> -CustomMethod <string> -NoProxy [-FollowRelLink]
[-MaximumFollowRelLink <int>] [-ResponseHeadersVariable <string>] [-StatusCodeVariable <string>]
[-UseBasicParsing] [-HttpVersion <version>] [-WebSession <WebRequestSession>]
[-SessionVariable <string>] [-AllowUnencryptedAuthentication]
[-Authentication <WebAuthenticationType>] [-Credential <pscredential>] [-UseDefaultCredentials]
[-CertificateThumbprint <string>] [-Certificate <X509Certificate>] [-SkipCertificateCheck]
[-SslProtocol <WebSslProtocol>] [-Token <securestring>] [-UserAgent <string>] [-DisableKeepAlive]
[-ConnectionTimeoutSeconds <int>] [-OperationTimeoutSeconds <int>] [-Headers <IDictionary>]
[-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <int>]
[-MaximumRetryCount <int>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <int>]
[-PreserveHttpMethodOnRedirect] [-Body <Object>] [-Form <IDictionary>] [-ContentType <string>]
[-TransferEncoding <string>] [-InFile <string>] [-OutFile <string>] [-PassThru] [-Resume]
Invoke-RestMethod [-FollowRelLink] [-MaximumFollowRelLink <Int32>]
[-ResponseHeadersVariable <String>] [-StatusCodeVariable <String>] [-UseBasicParsing] [-Uri] <Uri>
[-HttpVersion <Version>] [-WebSession <WebRequestSession>] [-SessionVariable <String>]
[-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>]
[-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>]
[-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>]
[-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive]
[-ConnectionTimeoutSeconds <Int32>] [-OperationTimeoutSeconds <Int32>] [-Headers <IDictionary>]
[-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <Int32>]
[-MaximumRetryCount <Int32>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <Int32>]
-CustomMethod <String> [-PreserveHttpMethodOnRedirect] [-UnixSocket <UnixDomainSocketEndPoint>]
[-NoProxy] [-Body <Object>] [-Form <IDictionary>] [-ContentType <String>]
[-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] [-PassThru] [-Resume]
[-SkipHttpErrorCheck] [<CommonParameters>]
```

Expand Down Expand Up @@ -304,6 +307,16 @@ $uri = 'https://api.github.com/repos/microsoftdocs/powershell-docs/issues'
Invoke-RestMethod -Uri $uri -HttpVersion 2.0 -SkipCertificateCheck
```

### Example 9: Send a request a Unix socket application

Some applications, such as Docker, expose a Unix socket for communication. This example queries for
a list of Docker images using the Docker API. The cmdlet connects to the Docker daemon using the
Unix socket.

```powershell
Invoke-RestMethod -Uri "http://localhost/v1.40/images/json/" -UnixSocket "/var/run/docker.sock"
```

## PARAMETERS

### -AllowInsecureRedirect
Expand Down Expand Up @@ -1312,6 +1325,28 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -UnixSocket

Specifies the name of the Unix socket to connect to. This parameter is supported on Unix-based
systems and Windows version 1803 and later. For more information about Windows support of Unix
sockets, see
[Windows/WSL Interop with AF_UNIX](https://devblogs.microsoft.com/commandline/windowswsl-interop-with-af_unix/)
blog post.

This parameter was added in PowerShell 7.4.

```yaml
Type: System.Net.Sockets.UnixDomainSocketEndPoint
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Uri

Specifies the Uniform Resource Identifier (URI) of the internet resource to which the web request is
Expand Down
Loading