You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
How many times have you thought in your mind the tasks that were given to you or the tasks that you would do via User Interface in your company whether they can be achieved via API/Automation?
Here's an article that will get you started on the basics of the API journey in Atlassian products.
We will look at creating basic elements in Jira, Confluence, and Bitbucket
Let me start with Jira, it's the issue
To create an issue
curl --request POST \
--url 'https://your-site.atlassian.net/rest/api/3/issue' \
--user 'your-email:api-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"fields" : {"summary" : "Issue Summary - Test",
"issuetype" : {"id" : "10000"},
"project" : {"id" : "10000"},
"assignee" : {"id" : "5d36b583beedf60c26aa372d"} } }'
Where to get the details like token, issue type ID, a project ID, assignee ID?
The token can be generated here
https://id.atlassian.com/manage-profile/security/api-tokens
Here's the link that will help you in getting Project ID
https://confluence.atlassian.com/jirakb/how-to-get-project-id-from-the-jira-user-interface-827341414.html
With API, to get project ID it goes like this
curl --request GET \
--url 'https://your-domain.atlassian.net/rest/api/3/project/{projectKey}' \
--user 'your-email:api-token' \
--header 'Accept: application/json'
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-projects/#api-rest-api-3-project-projectidorkey-get
Issue ID
curl --request GET \
--url 'https://your-domain.atlassian.net/rest/api/3/issuetype' \
--user 'your-email:api-token' \
--header 'Accept: application/json'
Get Account ID of Users
curl --request GET \
--url 'https://your-domain.atlassian.com/rest/api/3/user/bulk/migration' \
--user 'your-email:api-token' \
--header 'Accept: application/json'
Now that you have all the fields to create an issue, fill in the values and create an issue!
Explore more and master yourself in API!
The link to API documentation is here
https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro
How to create Confluence pages using API?
To create an empty page
curl --request POST \
--url 'https://your-domain.atlassian.net/wiki/rest/api/content' \
--user 'your-email:api-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"title": "Page title", "type": "page", "space": {"key": "spaceKey"}, "status": "current"}'
Here's how you would add the data in API
curl --request POST \
--url 'https://your-domain.atlassian.net/wiki/rest/api/content' \
--user 'your-email:api-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"title": "Page title", "type": "page", "space": {"key": "spaceKey"}, "status": "current", "body":{"storage":{"value":"<p>This is a new page</p>", "representation":"storage" }}}'
The confluence REST API documentation is here
https://developer.atlassian.com/cloud/confluence/rest/intro
Now let's go with Bitbucket
Creating a Private Repository
curl -X POST \
--url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo-name}' \
--user 'bitbucket-username:app-password' \
--header "Content-Type: application/json" \
--data '{"scm": "git", "project": {"key": "projectKey"}, "is_private": true }'
The Bitbucket API Documentation is here
https://developer.atlassian.com/bitbucket/api/2/reference
I hope you find this article gets a motivation to start with API in your instance. Please share your thoughts in the comments.
Thanks,
Pramodh
Pramodh M
DevSecOps Architect
Bengaluru
644 accepted answers
9 comments