Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,702
Community Members
 
Community Events
165
Community Groups

how to pass arguments to curl

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

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\"
}
"

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

@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.

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

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
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

217 views 0 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you