Reputation: 47
I am trying to pass parameters to cURL through the command line, this way:
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'
(This line is actually extracted from the Postman app).
I Googled this issue and found whole lot of solutions that did not work for me (links are to SO past questions...):
'before...'"${someVar}"'...after...'
. Could not complete the request.-d @fileName)
. Failed to post.<Data>
tokens with double quotes - but the command apparently cannot accept such substitution.The errors I get are either <Error></Error>
or The server encountered an error and could not complete your request.
Is there any chance that there exists some other solution? Has anyone encoutered such problem before?
I would be greatful for any help.
Upvotes: 3
Views: 5422
Reputation: 532518
You aren't supplying quotes around the value of ID
like you are for Name
. That is, you need
'<Data Token="someToken" Name="'"$appName"'" ...>'
^^^
|||
||+- shell quote to protect $appName
|+- shell quote enclosing the XML
+- literal quote embedded in the XML
which results in the string (assuming appName=foo
)
<Data Token="someToken" Name="foo" ...>
Upvotes: 11