0

I wanted to use curl to create a filter for our Jira system and set shares in one go. form this post (https://answers.atlassian.com/questions/173249) on the Atlassian-Answers site I understood that this is not possible with only the using the restAPI. So I tried using the code that the asker posted.
If I use this line:

.\cURL\bin\curl.exe -s -c cookie.txt -S -u %USERNAME%::%PASSWORD% %JiraServer%/secure/Dashboard.jspa

My script always exits, telling me that the syntax is incorrect. I never worked with curl before, but by only using the documentations from jira(login) and curl (commandlist) I can't find the problem.
My only idea is that there might be a problem with the address, but I cant think of what the problem should be.

EDIT:

for %%f in (.\Filters\*) do ( 
    powershell -Command "(Get-Content "%%f") | ForEach-Object { $_ -replace \"%%PROJECT%%\", \"%PROJECT%\" } | Set-Content %TEMP_FILE%"
    powershell -Command "(Get-Content \"%TEMP_FILE%\") | ForEach-Object { $_ -replace \"%%COMPONENT%%\", \"%COMPONENT%\" } | Set-Content %TEMP_FILE%"
    pause
    .\cURL\bin\curl.exe -s -c cookie.txt -S -u MYUSERNAME::MYPASSWORD JIRA_ADDRESS
    pause
    .\cURL\bin\curl.exe -s -b cookie.txt -S %JiraServer%/rest/api/latest/filter -X POST -H "Content-Type: application/json" --data @%TEMP_FILE%
    pause
    .\cURL\bin\curl.exe -s -b cookie.txt -S %JiraServer%/secure/EditFilter.jspa -X POST --data @%ShareFile%'        

    ::.\cURL\bin\curl.exe -u %USERNAME%:%PASSWORD% -X POST --data @%TEMP_FILE% -H "Content-Type: application/json" %URL%            
)

That is the whole code involved with the calls, it exits at the first curl call. If I run the exact same Code as the first curl call on the shell I get a response, if I use it inside the file I get syntax of command incorrect

lsteinme
  • 750
  • 1
  • 6
  • 20
  • I assume you tried to make a simple invoke of the command line work from a shell prompt and then worked on replacing pieces with variables? If so, the problem pretty much has to be in what the variables contain - I would suspect embedded spaces or other "illegal" characters. – Daniel Stenberg Aug 11 '15 at 06:34
  • seems I need to edit the question, if I only Run the code that is above in the shell (without the rest of the batch) I get an answer, – lsteinme Aug 11 '15 at 06:41
  • you fell into the [delayed expansion trap](http://stackoverflow.com/a/30284028/2152082). (`%temp_file%`) – Stephan Aug 11 '15 at 06:52
  • in the first curl statment is no reference to the tempfile, does it anyway crash because of this? – lsteinme Aug 11 '15 at 07:02
  • I assume `::` is used for commenting out some code? I recommend using `rem ` instead as `::` may cause trouble when used within a command block `()`. – aschipfl Aug 11 '15 at 11:19

0 Answers0