You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PowerShell调用curl访问jsonstore.io时遭遇InvalidArgument错误

解决PowerShell调用jsonstore.io时的Headers参数绑定错误

这个问题我太熟了!你之所以碰到这个报错,核心原因是:在PowerShell里curl其实是Invoke-WebRequest的别名,它对参数的要求和原生Linux/macOS里的curl完全不一样——原生curl用-H传字符串格式的头信息就行,但PowerShell的Invoke-WebRequest要求Headers参数必须是一个键值对组成的字典(IDictionary)对象,而不是直接传"Content-type: application/json"这种字符串,所以才会抛出类型转换失败的错误。

给你两种靠谱的解决办法:

方法一:用PowerShell原生的Invoke-WebRequest语法

直接按照PowerShell的要求构造Headers字典,写法如下:

分步写法(更清晰)

# 先定义请求头字典
$requestHeaders = @{
    "Content-type" = "application/json"
}
# 发送POST请求
Invoke-WebRequest -Uri "https://www.jsonstore.io/你的专属存储路径" -Method Post -Headers $requestHeaders -Body '{"log": "这里填你的PowerShell脚本日志内容"}'

一行简洁写法

Invoke-WebRequest -Uri "https://www.jsonstore.io/你的专属存储路径" -Method Post -Headers @{"Content-type"="application/json"} -Body '{"log": "这里填你的PowerShell脚本日志内容"}'

方法二:直接调用原生curl命令

如果你的系统是Windows 10及以上(自带原生curl),或者装了curl工具,可以直接调用curl.exe绕开PowerShell的别名限制,这样就能用你原来熟悉的curl语法:

curl.exe -XPOST -H "Content-type: application/json" -d '{"log": "这里填你的PowerShell脚本日志内容"}' https://www.jsonstore.io/你的专属存储路径

或者用--%参数告诉PowerShell停止解析后续参数,直接传给原生curl:

curl --% -XPOST -H "Content-type: application/json" -d '{"log": "这里填你的PowerShell脚本日志内容"}' https://www.jsonstore.io/你的专属存储路径

记得把上面代码里的你的专属存储路径替换成你在jsonstore.io创建的实际路径哦!

内容的提问来源于stack exchange,提问作者Tal Ben David

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:23:22