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!
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.