Curl string syntax in 2018 r3
Posted: Wed May 22, 2019 9:35 pm
Hi,
First time using Switch 2018. I am having issues with getting a curl string to work directly from Switch. Script fails with json syntax errors.
BUT If I copy the message log field from the job.log of the "theString" to capture what Switch is passing to cmd The string works correctly when copied into cmd line manually. But it won't work directly from Switch. Any thoughts?
curl command in SwitchScripter
var theString = "c:\\curl\\bin\\curl -H \"test-upp-api-key: 12345r6788\" -H \"test-upp-api-version: v2\" -H \"Cache-Control: no-cache\" -H \"Content-Type: application/json\" -X POST -d \"{\\\"date_time\\\": \\\"2019-05-21 10:56:08\\\", \\\"order_id\\\": \\\"1234-1.1\\\", \\\"type\\\": \\\"PRODUCTION_STARTED\\\"}\" https://api.playbox.test.com/printer-signals/ ";
The below is the above command when copied from the job.log message of the above variable. If the below is copied into cmd it works correctly.
c:\curl\bin\curl -H "test-upp-api-key: 12345r6788" -H "test-upp-api-version: v2" -H "Cache-Control: no-cache" -H "Content-Type: application/json" -X POST -d "{\"date_time\": \"2019-05-21 10:56:08\", \"order_id\": \"1234-1.1\", \"type\": \"PRODUCTION_STARTED\"}" https://api.playbox.test.com/printer-signals/
First time using Switch 2018. I am having issues with getting a curl string to work directly from Switch. Script fails with json syntax errors.
BUT If I copy the message log field from the job.log of the "theString" to capture what Switch is passing to cmd The string works correctly when copied into cmd line manually. But it won't work directly from Switch. Any thoughts?
curl command in SwitchScripter
var theString = "c:\\curl\\bin\\curl -H \"test-upp-api-key: 12345r6788\" -H \"test-upp-api-version: v2\" -H \"Cache-Control: no-cache\" -H \"Content-Type: application/json\" -X POST -d \"{\\\"date_time\\\": \\\"2019-05-21 10:56:08\\\", \\\"order_id\\\": \\\"1234-1.1\\\", \\\"type\\\": \\\"PRODUCTION_STARTED\\\"}\" https://api.playbox.test.com/printer-signals/ ";
The below is the above command when copied from the job.log message of the above variable. If the below is copied into cmd it works correctly.
c:\curl\bin\curl -H "test-upp-api-key: 12345r6788" -H "test-upp-api-version: v2" -H "Cache-Control: no-cache" -H "Content-Type: application/json" -X POST -d "{\"date_time\": \"2019-05-21 10:56:08\", \"order_id\": \"1234-1.1\", \"type\": \"PRODUCTION_STARTED\"}" https://api.playbox.test.com/printer-signals/