没有不值得去解决的问题,也没有不值得去学习的技术!

在 Windows PowerShell 中执行命令:curl -X POST –data,报错:Invoke-WebRequest : 找不到接受实际参数“POST”的位置形式参数。的分析解决

在 Windows PowerShell 中执行命令:curl -X POST --data,报错:Invoke-WebRequest : 找不到接受实际参数“POST”的位置形式参数。
1、在 Windows PowerShell 中执行命令:curl -X POST –data,报错:Invoke-WebRequest : 找不到接受实际参数“POST”的位置形式参数。如图1
在 Windows PowerShell 中执行命令:curl -X POST --data,报错:Invoke-WebRequest : 找不到接受实际参数“POST”的位置形式参数。
图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 : 找不到与参数名称“X”匹配的参数。
所在位置 行:1 字符: 6
+ curl -X POST --data "access_token=2.00VtCfGEXWOOKE229f72fa42wkzKAE" h ...
+      ~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest],ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand



2、Invoke-WebRequest 是在 Windows 平台上类似于 cURL 的命令行工具,执行命令:Get-Help Invoke-WebRequest,如图2
Invoke-WebRequest 是在 Windows 平台上类似于 cURL 的命令行工具,执行命令:Get-Help Invoke-WebRequest
图2
<pre class="wp-block-syntaxhighlighter-code">

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] <Uri> [-Body <Object>] [-Certificate <X509Certificate>] [-CertificateT
    [-ContentType <String>] [-Credential <PSCredential>] [-DisableKeepAlive] [-Headers <IDictionary
    ] [-MaximumRedirection <Int32>] [-Method {Default | Get | Head | Post | Put | Delete | Trace |
    tch}] [-OutFile <String>] [-PassThru] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-ProxyU
    ] [-SessionVariable <String>] [-TimeoutSec <Int32>] [-TransferEncoding {chunked | compress | de
    ity}] [-UseBasicParsing] [-UseDefaultCredentials] [-UserAgent <String>] [-WebSession <WebReques
    arameters>]


说明
    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"



</pre>
3、参考帮助文档,调整命令,执行命令,请求成功,如图3
参考帮助文档,调整命令,执行命令,请求成功
图3


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




需要长期技术维护或远程问题排查?

我是拥有 15+ 年经验的 PHP / Go 后端工程师,长期关注已有系统维护、Bug 修复、性能优化、服务器排查、WordPress 网站维护和小功能迭代。

如果你的项目遇到以下情况,可以先从一次小问题排查开始合作:

  • ✅ PHP / Laravel / Yii2 老项目无人维护
  • ✅ Go / Gin 后端接口需要排查或优化
  • ✅ WordPress 网站访问慢、报错或插件冲突
  • ✅ Nginx / MySQL / Redis / Linux 服务器异常
  • ✅ CDN / Cloudflare / DNS / HTTPS 配置问题
  • ✅ 需要长期远程技术支持或兼职维护

更多介绍请查看:关于我 & 合作

微信:13980074657
邮箱:shuijingwanwq@gmail.com
Telegram:@shuijingwan
GitHub:https://github.com/shuijingwan

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理