Skip to content

Instantly share code, notes, and snippets.

@TheMightyLlama
Last active November 16, 2023 18:22
Show Gist options
  • Save TheMightyLlama/9427202 to your computer and use it in GitHub Desktop.
Save TheMightyLlama/9427202 to your computer and use it in GitHub Desktop.
Perform actions on a jira issue via curl
#Creates a new issue with custom fields
curl -D- -u uname:pass -X POST --data "{\"fields\": {\"project\": { \"id\": \"10430\" },\"summary\": \"This is a test issue\", \"description\": \"Description\",\"issuetype\": { \"id\" : \"1\"}, \"components\" : [{\"id\":\"10731\"}], \"customfield_10711\" : [{\"id\":\"10500\"}] } }" -H "Content-Type: application/json" http://localhost:8080/jira/rest/api/2/issue/
#Returns all information for all versions
curl -D- -u uname:pass -X PUT -d "Content-Type: application/json" http://localhost:8080/jira/rest/api/2/project/AN/versions?
#Returns all issues in a version
#This URL requires the version ID of a single version which is provided by the above query
curl -D- -u uname:pass -X PUT -d "Content-Type: application/json" http://localhost:8080/jira/rest/api/2/search?jql=project="AN"+AND+fixVersion='12345'
#Returns all information on an issue
curl -D- -u uname:pass -X PUT -d "Content-Type: application/json" http://localhost:8080/jira/rest/api/2/issue/KEY-12345
#Adds a comment to an existing issue
curl -D- -u uname:pass -X PUT -d "{\"update\": {\"comment\": [{\"add\": {\"body\": \"Comment added when resolving issue\"}}]}}" -H "Content-Type: application/json" http://localhost:8080/jira/rest/api/2/issue/KEY-12345
#Transitions an issue
#Find the transition id by going to your instance of jira and right clicking on the button you use to transition
# for example 'In Progress'. Copy the link and paste somewhere. You should get something like the below:
#
# https://localhost:8080/jira/secure/WorkflowUIDispatcher.jspa?id=49385&action=721&atl_token=BLAH-BLAH-BLAH-BLAH|som83hex9494maybe9394|lin
#
#Use the 'action=' value above in the query link. In the above example its 721
#Note that at the end of the URL you have `/transitions`
curl -D- -u uname:pass -X PUT -d "{\"transition\": {\"id\": \"721\"}}" -H "Content-Type: application/json" http://localhost:8080/jira/rest/api/2/issue/KEY-12345/transitions
#If you want to both make a comment and perform a transition do:
"{\"update\": {\"comment\": [{\"add\": {\"body\": \"Transitioned as all sub-tasks closed\"}}]},\"transition\": {\"id\": \"721\"}}"
#Get a list of all users
#This returns a list of all users with the letter 'a' in them
#Playing around it looks like the query doesn't permit regular expressions
curl -D- -u uname:pass http://localhost:8080/jira/rest/api/2/user/search?username=a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment