I am having trouble getting my curl commands to go through succesully using the execute command element. Below is the curl and a image of the element settings. Also is there a way to execute a curl command and get a json back using execute command element?
C:\curl.exe -k --location --request PATCH "https://websitename.com/fmi/data/v1/dat ... /records/1" --header "Content-Type: application/json" --header "Authorization: Bearer 9115494870f34db8ba58855895b92e65303eade4defff2c22223" --data-raw "{\"fieldData\": {\"Switch_AutoGLO_InProcess\": "2"}}"
Curl Execute Command
Re: Curl Execute Command
For longer and more complex commands it is recommended to use a .bat file. Place the command in a .bat file and in "Command or path" point to that file.
In order to get the JSON output into a file you must specify an output file and the path to the output file has to come from Switch as a parameter and then you have to tell Switch to continue with that output file:
In order to get the JSON output into a file you must specify an output file and the path to the output file has to come from Switch as a parameter and then you have to tell Switch to continue with that output file:
- Add --output %1 to the curl command in the .bat file
- In the "Arguments" property specify: "%2" (the quotes are important to avoid problems with spaces)
- In the "Output" property choose "File at path" so Switch knows that the command will output a file and not a folder, or nothing, or display some other behavior
Re: Curl Execute Command
And if you need to create the .bat file on the fly with Switch variables you can use this app to make .bat files and then run them with Execute Command.
https://www.enfocus.com/en/appstore/pro ... and-friend
https://www.enfocus.com/en/appstore/pro ... and-friend
Re: Curl Execute Command
I do need to use variables in the .bat file. Do you have a example of how to set up the execute command to use the output from the command line friend?
Re: Curl Execute Command
The resulting .bat file is used as a command in Execute Command.
See attached flow. You save the .bat file to a folder on disc and Execute Command picks it up from there and run the .bat
In the example I use a .sh file (Shell script)
The Hold Job elements is there for the job to wait for the script file to be generated. It has a delay for 3 seconds.
The Inject Job at the end deletes the .bat file from the folder on disc after execution.
See attached flow. You save the .bat file to a folder on disc and Execute Command picks it up from there and run the .bat
In the example I use a .sh file (Shell script)
The Hold Job elements is there for the job to wait for the script file to be generated. It has a delay for 3 seconds.
The Inject Job at the end deletes the .bat file from the folder on disc after execution.