Execute the command in Windows PowerShell: curl -x POST –data, and report an error: invoke-webrequest : The location formal parameter that accepts the actual parameter “post” cannot be found. analysis solution
1. Execute the command in Windows PowerShell: curl -x POST –data, report an error: invoke-webrequest : The location formal parameter that accepts the actual parameter “post” cannot be found. as shown in Figure 1
PS E:\wwwroot\channel-pub-api> curl -x post --data "access_token=2.00vtcfgexwooke229f72fa42wkzkae" https://api.weibo.com /oauth2/get_token_info invoke-webrequest : The parameter that matches the parameter name "x" cannot be found. Location Line:1 Characters: 6 + curl -x POST --data "access_token=2.00vtcfgexwooke229f72fa42wkzkae" h ... + ~~ + CategoryInfo : InvalidArgument: (:)[Invoke-WebRequest], ParameterBindingException + FullyQualifiedErrorID : NamedParameterNotFound, Microsoft.PowerShell.Commands.InvokeWebRequestCommand
2. Invoke-WebRequest is a command-line tool similar to curl on the Windows platform. Execute the command: get-help invoke-webrequest, as shown in Figure 2
PS E:\wwwroot\channel-pub-api> get-help invoke-webrequest
Do you want to run update-help?
Update-help cmdlet Download the latest help file for the Windows PowerShell module and install it on your computer. Related
For details of the update-help cmdlet, see https:/go.microsoft.com/fwlink/?LinkId=210614.
[Y]yes (Y)[N]No (n)[S]Suspension (S)[?]Help (default is "y"):
Name
invoke-webrequest
Summary
Gets content from a web page on the Internet.
Grammar
invoke-webrequest[-Uri]<uri>[-Body <Object>][-Certificate <X509Certificate>][-CertificateT
[-contentType <string>]#atfp_close_translate_span#[-Credential <PSCredential>][-DisableKeepAlive][-Headers <IDictionary
]#ATFP_CLOSE_Translate_span#[-MaximumRedirection <Int32>][-Method {Default | Get | Head | Post | Put | Delete | Trace |
tch}]#atfp_close_translate_span#[-OutFile <String>][-PassThru][-Proxy <Uri>][-ProxyCredential <PSCredential>][-ProxyU
]#ATFP_CLOSE_Translate_span#[-SessionVariable <String>][-TimeoutSec <Int32>][-TransferEncoding {chunked | compress | de
ity}]#ATFP_CLOSE_Translate_span#[-UseBasicParsing][-UseDefaultCredentials][-UserAgent <String>][-WebSession <WebReques
arameters>]#atfp_close_translate_span#
Explanation
The Invoke-WebRequest cmdlets HTTP, HTTPS, FTP, and file requests to a web page or web ser
Response and return collections of forms, links, images, and other signatures
This cmdlet was introduced in Windows PowerShell 3.0.
Related Links
online version: http://go.microsoft.com/fwlink/?LinkId=821826
invoke-restmethod
convertfrom-json
convertto-json
Remark
To see an example, type: "get-help invoke-webrequest -examples".
For details, type: "get-help invoke-webrequest -detailed".
To get technical information, type: "get-help invoke-webrequest -full".
For online help, type: "get-help invoke-webrequest -online"
3. Refer to the help document, adjust the command, execute the command, and the request is successful, as shown in Figure 3
PS e:\wwwroot\channel-pub-api> curl -URIhttps://api.weibo.com/oauth2/get_token_info-bodyaccess_token=2.00vtcfgexwo
OKE229F72FA42WKZKAE-methodpost
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


