我试图通过命令行将参数传递给cURL,这样:
curl -s -X POST -H "Content-Type: text/xml" -H "Cache-Control: no-cache" -d '<Data Token="someToken" Name='"$appName"' ID='"$someVar"' ParseAppID='"$someVar"' ParseRESTKey='"$someVar"' AndroidPackage='"$someVar"' Version="1"></Data>' 'https://prefix.something.com/somePath?InputType=Xml'
Run Code Online (Sandbox Code Playgroud)
(此行实际上是从Postman应用程序中提取的).
我用Google搜索了这个问题,发现了许多对我不起作用的解决方案(链接是过去的问题......):
'before...'"${someVar}"'...after...'.无法完成请求.-d @fileName).无法发布.<Data>双引号替换令牌周围的单引号 - 但命令显然不能接受这样的替换.我得到的错误是<Error></Error>或者The server encountered an error and could not complete your request.
有没有机会存在其他解决方案?以前有人遇到过这样的问题吗?
我会很乐意提供任何帮助.
您没有提供ID类似于您的价值的报价Name.也就是说,你需要
'<Data Token="someToken" Name="'"$appName"'" ...>'
^^^
|||
||+- shell quote to protect $appName
|+- shell quote enclosing the XML
+- literal quote embedded in the XML
Run Code Online (Sandbox Code Playgroud)
这导致字符串(假设appName=foo)
<Data Token="someToken" Name="foo" ...>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1510 次 |
| 最近记录: |