1

I am trying to use curl to make an HTTP POST request.

The request contains some environment variables. Here is the command:

curl -X POST -u username:pass -H "Content-Type: application/json" -d "{ \"fields\": { \"project\": { \"key\": \"myproject\" }, \"summary\": \"${var1.name} - ${var2.name}\", \"description\": \"Testing testing!:\n${url}\", \"issuetype\": { \"name\": \"Task\" }}}" http://myurl.com/rest

The information is sent, but the ${var1.name} and ${var2.name} are being sent as literal strings and not as their actual values.

The command is run on windows so that is why I am escaping the quotes. Could that be a problem as to why they're being sent as strings?

3
  • Windows environment variables are deferenced as %va1% and %var2%. Can you provide more information about where you're running this? e.g. Visual Studio Postbuild, or cmd shell, or powershell? Commented Oct 30, 2015 at 20:02
  • This is being run in a cmd shell on a windows server Commented Oct 30, 2015 at 20:03
  • Its being run in a batch file Commented Oct 30, 2015 at 20:08

1 Answer 1

3

Windows environment variables are deferenced as %var1% and %var2%. This works:

C:\>set var1.name=test1
C:\>set var2.name=test2
C:\>set var
var1.name=test1
var2.name=test2

curl.exe -X POST -u username:pass -H "Content-Type: application/json" -d "{ \"fields\": { \"project\": { \"key\": \"myproject\" }, \"summary\": \"%var1.name% - %var2.name%\", \"description\": \"Testing testing!:\n${url}\", \"issuetype\": { \"name\": \"Task\" }}}" http://myurl.com/rest

Sign up to request clarification or add additional context in comments.

1 Comment

Are you related to Edsger Dijkstra?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.