curl——PowerShell中的数据二进制文件

curl——PowerShell中的数据二进制文件,powershell,curl,invoke-webrequest,Powershell,Curl,Invoke Webrequest,如果我有curl命令,例如: curl <url> \ -H 'Content-Type: application/json' \ -H 'API-Key: <key>' \ --data-binary '{"blah":"blah {\n blah2(accountId: id, integrations: {int1: {Vms: [{Id: id2, resourceGroups: [\"test1\", \"test2\", \"test3\"]}]

如果我有
curl
命令,例如:

curl <url> \
  -H 'Content-Type: application/json' \
  -H 'API-Key: <key>' \
  --data-binary '{"blah":"blah {\n  blah2(accountId: id, integrations: {int1: {Vms: [{Id: id2, resourceGroups: [\"test1\", \"test2\", \"test3\"]}]}}) {\n    integrations {\n      id\n      name\n      service {\n        id\n        slug\n      }\n    }\n  }\n}\n", "variables":""}'
curl\
-H'内容类型:应用程序/json'\
-H'API密钥:'\
--数据二进制文件“{”blah:“blah{\n blah2(帐户id:id,集成:{int1:{Vms:[{id:id2,资源组:[\'test1\',\'test2\',\'test3\']}}}}}{\n集成{\n id\n name\n服务{\n id\n slug\n}\n}\n}\n}\n}\n}\n}\n}\n},,“变量”:

Powershell中的
--data binary
等效于什么?一些回答说只是运行
curl.exe
,其他人提到要更改内容类型。不过,这确实可以作为shell脚本使用。只是想知道是否可以将其转换为在Powershell中使用
Invoke WebRequest

-Body参数与有效负载一起工作使用
Invoke RestMethod
Invoke WebRequest
-infle
参数一起使用。不过,我不是在读取文件,只是在发送时使用内联json
--data binary
发送JSON正文是否有效?您可以使用
-Body
参数。
-Body
参数似乎不关心是否为二进制-按预期工作,尽管它确实需要特定的转义字符-感谢您的反馈!请更详细地充实这一点,以帮助未来的读者,包括解释您必须使用的特定转义字符。