Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Pass cURL response to a variable #3125

finspin ·
I have a shell step which uploads a file with cURL, receives a JSON response, parses it and assigns a value to the variable APP_FILE. I want to then set the same value to QB variable called appfile so that it's available in the next step.

APP_FILE=$(curl -s -F file_name=@"file.txt" --user user@domain "http://example.com/upload" | jq ".common.files.file_name") && 
${vars.get("appfile").setValue($APP_FILE, false)}



However, I'm getting an error:
Failed to evaluate below expression:
mvel:vars.get("appfile").setValue($APP_FILE, false)

It seems like I'm not able to use .setValue() method in the shell script. Is there some other way how to set the variable?
  • replies 2
  • views 1368
  • stars 0
robinshen ADMIN ·
Expressions inside ${} will be interpolated before executing shell script. To make it working, you will need to modify your command to redirect your command output to a file, and then add another step to read file content into the variable by running below script:
groovy:
vars.get("appfile").setValue(new File("/path/to/file").text, false);
finspin ·
Thanks, that worked!