22external help file : Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33Locale : en-US
44Module Name : Microsoft.PowerShell.Utility
5- ms.date : 06/30 /2023
5+ ms.date : 08/18 /2023
66online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.4&WT.mc_id=ps-gethelp
77schema : 2.0.0
88title : Invoke-RestMethod
@@ -18,74 +18,77 @@ Sends an HTTP or HTTPS request to a RESTful web service.
1818### StandardMethod (Default)
1919
2020```
21- Invoke-RestMethod [-Uri] <uri> [- FollowRelLink] [-MaximumFollowRelLink <int >]
22- [-ResponseHeadersVariable <string >] [-StatusCodeVariable <string >] [-UseBasicParsing]
23- [-HttpVersion <version >] [-WebSession <WebRequestSession>] [-SessionVariable <string >]
21+ Invoke-RestMethod [-FollowRelLink] [-MaximumFollowRelLink <Int32 >]
22+ [-ResponseHeadersVariable <String >] [-StatusCodeVariable <String >] [-UseBasicParsing] [-Uri] <Uri>
23+ [-HttpVersion <Version >] [-WebSession <WebRequestSession>] [-SessionVariable <String >]
2424 [-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>]
25- [-Credential <pscredential >] [-UseDefaultCredentials] [-CertificateThumbprint <string >]
25+ [-Credential <PSCredential >] [-UseDefaultCredentials] [-CertificateThumbprint <String >]
2626 [-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>]
27- [-Token <securestring>] [-UserAgent <string>] [-DisableKeepAlive]
28- [-ConnectionTimeoutSeconds <int>] [-OperationTimeoutSeconds <int>] [-Headers <IDictionary>]
29- [-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <int>]
30- [-MaximumRetryCount <int>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <int>]
31- [-Method <WebRequestMethod>] [-PreserveHttpMethodOnRedirect] [-Proxy <uri>]
32- [-ProxyCredential <pscredential>] [-ProxyUseDefaultCredentials] [-Body <Object>]
33- [-Form <IDictionary>] [-ContentType <string>] [-TransferEncoding <string>] [-InFile <string>]
34- [-OutFile <string>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [<CommonParameters>]
27+ [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive]
28+ [-ConnectionTimeoutSeconds <Int32>] [-OperationTimeoutSeconds <Int32>] [-Headers <IDictionary>]
29+ [-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <Int32>]
30+ [-MaximumRetryCount <Int32>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <Int32>]
31+ [-Method <WebRequestMethod>] [-PreserveHttpMethodOnRedirect]
32+ [-UnixSocket <UnixDomainSocketEndPoint>] [-Proxy <Uri>] [-ProxyCredential <PSCredential>]
33+ [-ProxyUseDefaultCredentials] [-Body <Object>] [-Form <IDictionary>] [-ContentType <String>]
34+ [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] [-PassThru] [-Resume]
35+ [-SkipHttpErrorCheck] [<CommonParameters>]
3536```
3637
3738### StandardMethodNoProxy
3839
3940```
40- Invoke-RestMethod [-Uri] <uri> -NoProxy [- FollowRelLink] [-MaximumFollowRelLink <int >]
41- [-ResponseHeadersVariable <string >] [-StatusCodeVariable <string >] [-UseBasicParsing]
42- [-HttpVersion <version >] [-WebSession <WebRequestSession>] [-SessionVariable <string >]
41+ Invoke-RestMethod [-FollowRelLink] [-MaximumFollowRelLink <Int32 >]
42+ [-ResponseHeadersVariable <String >] [-StatusCodeVariable <String >] [-UseBasicParsing] [-Uri] <Uri>
43+ [-HttpVersion <Version >] [-WebSession <WebRequestSession>] [-SessionVariable <String >]
4344 [-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>]
44- [-Credential <pscredential >] [-UseDefaultCredentials] [-CertificateThumbprint <string >]
45+ [-Credential <PSCredential >] [-UseDefaultCredentials] [-CertificateThumbprint <String >]
4546 [-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>]
46- [-Token <securestring>] [-UserAgent <string>] [-DisableKeepAlive]
47- [-ConnectionTimeoutSeconds <int>] [-OperationTimeoutSeconds <int>] [-Headers <IDictionary>]
48- [-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <int>]
49- [-MaximumRetryCount <int>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <int>]
50- [-Method <WebRequestMethod>] [-PreserveHttpMethodOnRedirect] [-Body <Object>]
51- [-Form <IDictionary>] [-ContentType <string>] [-TransferEncoding <string>] [-InFile <string>]
52- [-OutFile <string>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [<CommonParameters>]
47+ [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive]
48+ [-ConnectionTimeoutSeconds <Int32>] [-OperationTimeoutSeconds <Int32>] [-Headers <IDictionary>]
49+ [-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <Int32>]
50+ [-MaximumRetryCount <Int32>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <Int32>]
51+ [-Method <WebRequestMethod>] [-PreserveHttpMethodOnRedirect]
52+ [-UnixSocket <UnixDomainSocketEndPoint>] [-NoProxy] [-Body <Object>] [-Form <IDictionary>]
53+ [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>]
54+ [-PassThru] [-Resume] [-SkipHttpErrorCheck] [<CommonParameters>]
5355```
5456
5557### CustomMethod
5658
5759```
58- Invoke-RestMethod [-Uri] <uri> -CustomMethod <string> [-FollowRelLink ]
59- [-MaximumFollowRelLink <int >] [-ResponseHeadersVariable <string >] [-StatusCodeVariable <string>]
60- [-UseBasicParsing ] [-HttpVersion <version >] [-WebSession <WebRequestSession >]
61- [-SessionVariable <string> ] [-AllowUnencryptedAuthentication ]
62- [-Authentication <WebAuthenticationType >] [-Credential <pscredential> ] [-UseDefaultCredentials ]
63- [-CertificateThumbprint <string >] [-Certificate <X509Certificate> ] [-SkipCertificateCheck ]
64- [-SslProtocol <WebSslProtocol>] [- Token <securestring >] [-UserAgent <string >] [-DisableKeepAlive]
65- [-ConnectionTimeoutSeconds <int >] [-OperationTimeoutSeconds <int >] [-Headers <IDictionary>]
66- [-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <int >]
67- [-MaximumRetryCount <int >] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <int >]
68- [-PreserveHttpMethodOnRedirect] [-Proxy <uri> ] [-ProxyCredential <pscredential >]
69- [-ProxyUseDefaultCredentials ] [-Body <Object >] [-Form <IDictionary> ] [-ContentType <string >]
70- [-TransferEncoding <string >] [-InFile <string >] [-OutFile <string >] [-PassThru] [-Resume ]
71- [-SkipHttpErrorCheck] [<CommonParameters>]
60+ Invoke-RestMethod [-FollowRelLink] [-MaximumFollowRelLink <Int32> ]
61+ [-ResponseHeadersVariable <String >] [-StatusCodeVariable <String >] [-UseBasicParsing] [-Uri] <Uri>
62+ [-HttpVersion <Version> ] [-WebSession <WebRequestSession >] [-SessionVariable <String >]
63+ [-AllowUnencryptedAuthentication ] [-Authentication <WebAuthenticationType> ]
64+ [-Credential <PSCredential >] [-UseDefaultCredentials ] [-CertificateThumbprint <String> ]
65+ [-Certificate <X509Certificate >] [-SkipCertificateCheck ] [-SslProtocol <WebSslProtocol> ]
66+ [-Token <SecureString >] [-UserAgent <String >] [-DisableKeepAlive]
67+ [-ConnectionTimeoutSeconds <Int32 >] [-OperationTimeoutSeconds <Int32 >] [-Headers <IDictionary>]
68+ [-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <Int32 >]
69+ [-MaximumRetryCount <Int32 >] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <Int32 >]
70+ -CustomMethod <String> [-PreserveHttpMethodOnRedirect ] [-UnixSocket <UnixDomainSocketEndPoint >]
71+ [-Proxy <Uri> ] [-ProxyCredential <PSCredential >] [-ProxyUseDefaultCredentials ] [-Body <Object >]
72+ [-Form <IDictionary >] [-ContentType <String >] [-TransferEncoding <String >] [-InFile <String> ]
73+ [-OutFile <String>] [-PassThru] [-Resume] [- SkipHttpErrorCheck] [<CommonParameters>]
7274```
7375
7476### CustomMethodNoProxy
7577
7678```
77- Invoke-RestMethod [-Uri] <uri> -CustomMethod <string> -NoProxy [-FollowRelLink]
78- [-MaximumFollowRelLink <int>] [-ResponseHeadersVariable <string>] [-StatusCodeVariable <string>]
79- [-UseBasicParsing] [-HttpVersion <version>] [-WebSession <WebRequestSession>]
80- [-SessionVariable <string>] [-AllowUnencryptedAuthentication]
81- [-Authentication <WebAuthenticationType>] [-Credential <pscredential>] [-UseDefaultCredentials]
82- [-CertificateThumbprint <string>] [-Certificate <X509Certificate>] [-SkipCertificateCheck]
83- [-SslProtocol <WebSslProtocol>] [-Token <securestring>] [-UserAgent <string>] [-DisableKeepAlive]
84- [-ConnectionTimeoutSeconds <int>] [-OperationTimeoutSeconds <int>] [-Headers <IDictionary>]
85- [-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <int>]
86- [-MaximumRetryCount <int>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <int>]
87- [-PreserveHttpMethodOnRedirect] [-Body <Object>] [-Form <IDictionary>] [-ContentType <string>]
88- [-TransferEncoding <string>] [-InFile <string>] [-OutFile <string>] [-PassThru] [-Resume]
79+ Invoke-RestMethod [-FollowRelLink] [-MaximumFollowRelLink <Int32>]
80+ [-ResponseHeadersVariable <String>] [-StatusCodeVariable <String>] [-UseBasicParsing] [-Uri] <Uri>
81+ [-HttpVersion <Version>] [-WebSession <WebRequestSession>] [-SessionVariable <String>]
82+ [-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>]
83+ [-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>]
84+ [-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>]
85+ [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive]
86+ [-ConnectionTimeoutSeconds <Int32>] [-OperationTimeoutSeconds <Int32>] [-Headers <IDictionary>]
87+ [-SkipHeaderValidation] [-AllowInsecureRedirect] [-MaximumRedirection <Int32>]
88+ [-MaximumRetryCount <Int32>] [-PreserveAuthorizationOnRedirect] [-RetryIntervalSec <Int32>]
89+ -CustomMethod <String> [-PreserveHttpMethodOnRedirect] [-UnixSocket <UnixDomainSocketEndPoint>]
90+ [-NoProxy] [-Body <Object>] [-Form <IDictionary>] [-ContentType <String>]
91+ [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] [-PassThru] [-Resume]
8992 [-SkipHttpErrorCheck] [<CommonParameters>]
9093```
9194
@@ -304,6 +307,16 @@ $uri = 'https://api.github.com/repos/microsoftdocs/powershell-docs/issues'
304307Invoke-RestMethod -Uri $uri -HttpVersion 2.0 -SkipCertificateCheck
305308```
306309
310+ ### Example 9: Send a request to a Unix socket application
311+
312+ Some applications, such as Docker, expose a Unix socket for communication. This example queries for
313+ a list of Docker images using the Docker API. The cmdlet connects to the Docker daemon using the
314+ Unix socket.
315+
316+ ``` powershell
317+ Invoke-RestMethod -Uri "http://localhost/v1.40/images/json/" -UnixSocket "/var/run/docker.sock"
318+ ```
319+
307320## PARAMETERS
308321
309322### -AllowInsecureRedirect
@@ -1312,6 +1325,28 @@ Accept pipeline input: False
13121325Accept wildcard characters: False
13131326` ` `
13141327
1328+ # ## -UnixSocket
1329+
1330+ Specifies the name of the Unix socket to connect to. This parameter is supported on Unix-based
1331+ systems and Windows version 1803 and later. For more information about Windows support of Unix
1332+ sockets, see the
1333+ [Windows/WSL Interop with AF_UNIX](https://devblogs.microsoft.com/commandline/windowswsl-interop-with-af_unix/)
1334+ blog post.
1335+
1336+ This parameter was added in PowerShell 7.4.
1337+
1338+ ` ` ` yaml
1339+ Type: System.Net.Sockets.UnixDomainSocketEndPoint
1340+ Parameter Sets: (All)
1341+ Aliases:
1342+
1343+ Required: False
1344+ Position: Named
1345+ Default value: None
1346+ Accept pipeline input: False
1347+ Accept wildcard characters: False
1348+ ` ` `
1349+
13151350# ## -Uri
13161351
13171352Specifies the Uniform Resource Identifier (URI) of the internet resource to which the web request is
0 commit comments