Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

how to pass arguments to curl

David Fant June 17, 2022

Im using Automator on mac to create a simple "Big Red Button" that employees can run, It asks for their name ($1), their location ($2)  and their issue ($3). I have it set up to pass these arguments as $1 $2 and $3 into a bash script that goes to pushover and slack so I get notifications there, I wanted to also have it pass to Jira. Here is what I have sofar:

 

curl -D- -u username:APIkey -X POST --data '{"fields":{"project":{"key": "CCM"},"summary": "$1 at $2" ,"description": "$3","issuetype": {"name": "Service Request"}}}' -H "Content-Type: application/json" https://company.atlassian.net/rest/api/2/issue/

obviously I dummied out my username, API key and company subdomain, but using this it creates the issue, but it dosent pass the arguments, it just adds "$1 at $2" as text. I tried without the quotes and it doest work at all.

 

Is this possible? what am I missing?

 

Thanks!

2 answers

1 accepted

2 votes
Answer accepted
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 18, 2022

I think the problem might lie with substitution. Probably you need to wrap the --data argument within double quotes and escape the double quotes within the data that is passed.

--data "{\"fields\": \"$1 at $2\"
}
"
David Fant June 18, 2022

Thank you! Thank you! Thank you! 

That worked like a charm. I'll have to dive a bit deeper into bash / API / JSON stuff this is fascinating, I have no idea what escaping the quotes means, but it worked.

 

Thanks!

0 votes
Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 17, 2022

@David Fant -

I would say that you need to construct the summary value first with your $1 and $2 values, only then just obtain the constructed summary (the actual values) in your curl command.

I am not a technical developer, so hope my input will help you..

Best, Joseph Chung Yin

Jira/JSM Functional Lead, Global Infrastructure Applications Team

Viasat Inc.

David Fant June 17, 2022

That makes sense I was going off of how I used the values in the curl for slack which is like this:

 

curl -d "text=$1 at $2 says $3" -d "channel=XXXXXXXXX" -H "Authorization: Bearer xoxb-000000000000000000000000000000000000000000" -X POST https://slack.com/api/chat.postMessage

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 17, 2022

Don't know much about how Slack REST API works.  However, in Jira/JSM API when setting the Summary field, the field itself only takes a string based my knowledge.

Best, Joseph

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events