1. When running the command `curl -X POST –data` in Windows PowerShell, an error occurs: Invoke-WebRequest : A positional parameter cannot be found that accepts argument ‘POST’. As shown in Figure 1.

Plaintext
PS E:\wwwroot\channel-pub-api> curl -X POST --data "access_token=2.00VtCfGEXWOOKE229f72fa42wkzKAE" https://api.weibo.com
/oauth2/get_token_info
Invoke-WebRequest : 找不到与参数名称“X”匹配的参数。
所在位置 行:1 字符: 6
+ curl -X POST --data "access_token=2.00VtCfGEXWOOKE229f72fa42wkzKAE" h ...
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest],ParameterBindingException
+ Fully QualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
2. Invoke-WebRequest is a command-line tool on the Windows platform similar to cURL. Run the command: Get-Help Invoke-WebRequest, as shown in Figure 2.

Plaintext
PS E:\wwwroot\channel-pub-api> Get-Help Invoke-WebRequest
是否要运行 Update-Help?
Update-Help cmdlet 下载 Windows PowerShell 模块的最新帮助文件,并将其安装在你的计算机上。有关
Update-Help cmdlet 的详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkId=210614。
[Y] 是(Y) [N] 否(N) [S] 暂停(S) [?] 帮助 (默认值为“Y”):
名称
Invoke-WebRequest
摘要
Gets content from a web page on the Internet.
语法
Invoke-WebRequest [-Uri] [-Body ] [-Certificate ] [-CertificateT
[-ContentType ] [-Credential ] [-DisableKeepAlive] [-Headers ] [-Method {Default | Get | Head | Post | Put | Delete | Trace |
tch}] [-OutFile ] [-PassThru] [-Proxy ] [-ProxyCredential ] [-ProxyU
] [-SessionVariable ] [-TimeoutSec ] [-TransferEncoding {chunked | compress | de
ity}] [-UseBasicParsing] [-UseDefaultCredentials] [-UserAgent ] [-WebSession ]
说明
The Invoke-WebRequest cmdlet sends HTTP, HTTPS, FTP, and FILE requests to a web page or web ser
response and returns collections of forms, links, images, and other significant HTML elements.
This cmdlet was introduced in Windows PowerShell 3.0.
相关链接
Online Version: http://go.microsoft.com/fwlink/?LinkId=821826
Invoke-RestMethod
ConvertFrom-Json
ConvertTo-Json
备注
若要查看示例,请键入: "get-help Invoke-WebRequest -examples".
有关详细信息,请键入: "get-help Invoke-WebRequest -detailed".
若要获取技术信息,请键入: "get-help Invoke-WebRequest -full".
有关在线帮助,请键入: "get-help Invoke-WebRequest -online"
3. Referring to the help documentation, I adjusted the command and executed it. The request was successful, as shown in Figure 3.

Plaintext
PS E:\wwwroot\channel-pub-api> curl -Uri 'https://api.weibo.com/oauth2/get_token_info' -Body 'access_token=2.00VtCfGEXWO
OKE229f72fa42wkzKAE' -Method 'POST'
StatusCode : 200
StatusDescription : OK
Content : {"uid":3762971921,"appkey":"3815687113","scope":"","create_at":1545898005,"expire_in":44817}
RawContent : HTTP/1.1 200 OK
Connection: keep-alive
Pragma: No-cache
Content-Length: 92
Cache-Control: no-cache
Content-Type: application/json;charset=UTF-8
Date: Fri, 28 Dec 2018 06:33:02 GMT
Expires: Thu,...
Forms : {}
Headers : {[Connection, keep-alive], [Pragma, No-cache], [Content-Length, 92], [Cache-Control, no-cache]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 92
