How to get better at APIs 🕶

Hello Community,

Somewhere a year and a half back, I had posted how to get started with API on Jira, Confluence & Bitbucket. The article here explains how to start API Journey in Atlassian Universe --> Article Here

Here are recent posts regarding APIs

We build integration systems of our own to automate things around the tools to have a continuous flow and for various other requirements

For this, we surely need APIs in place and the Applications' extended API comes into the picture where we decide what actions we can perform

Let's look at how we level up ourselves in the game of Atlassian Universes API Module and take a step ahead with the APIs available in respective applications and what automations we can perform

Here is the one that I will take to discuss with other Jira Admins and how I was learning initially on APIs to either get some data or automate any activities

We would need to authenticate with Token to interact with Cloud Applications in the Atlassian Suite of Products. Follow the Guide here for the same

The REST API's Doc links for Jira, Confluence & Bitbucket are

Jira

Confluence

Bitbucket

Expansion - Specific to Jira if we need to get more information when specified we will have to specify the 'expand' property in the API endpoint and call 

Say you would want to know the history of the Issue and for Cloud API if we need to get more details of Issue history, the example would be as follows

curl -s --request GET --url "https://${your-site}.atlassian.net/rest/api/3/issue/${issue-key}?expand=changelog" --user '${email}:${token}' --header 'Accept: application/json' --header 'Content-Type: application/json' | jq '.changelog.histories[]'

Pagination & Ordering - Similar to that pagination and ordering properties are passed in the API endpoint

For example, if we were to search for more issues via JQL Search or get the changelog with the available API endpoint, all the data at once is not received and we would have to paginate through the API by specifying the startAt parameter. For now, we will use a small JQL - Ref and see how we do the same

curl -s --request GET --url 'https://${your-site}.atlassian.net/rest/api/3/search?jql=project%20%3D%20GAP&maxResults=100&startAt=0'   --user '${email}:${token}' --header 'Accept: application/json'   --header 'Content-Type: application/json' | jq -r '.issues[].key'
curl -s --request GET --url 'https://${your-site}.atlassian.net/rest/api/3/search?jql=project%20%3D%20GAP&maxResults=100&startAt=101'   --user '${email}:${token}' --header 'Accept: application/json'   --header 'Content-Type: application/json' | jq -r '.issues[].key'

Some Other Example of Jira API is updating the Issue while Transitioning from one Status to another

Example for updating the Field, Comment & Status

curl --request POST \
  --url "https://${your-site}.atlassian.net/rest/api/3/issue/${issue-key}/transitions" \
  --user '${email}:${token}' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{ "transition": { "id": "transition-id" },
    "fields": { "customfield_10056": [ {"value": "value1"}, {"value": "value2"} ] },
    "update": { "comment": [ { "add": { "body": { "type": "doc", "version": 1,"content": [
    { "type": "paragraph", "content": [ { "text": "Comment here", "type": "text" } ] } ] } } } ] } }'

The transition ID of a Workflow can be taken from this API Here

And the Approach to any content you want to update in the issue, if you don't to how to format the data, create the sample issue with all the relevant details you want to update via API and call the GET Issue API, you will have the format, now all there is left to do is update the API with the correct format we the issue to be updated via API.

You can find more API Examples in the below links

Jira

Confluence Server

Confluence Cloud

Hope this gives you and your teams the enlightenment on how vast the Atlassian Universe is and the enriched metadata it carries and how we can interact using APIs from the external world

Thanks,
Pramodh

3 comments

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 17, 2022

Thanks @Pramodh M 

Like • Pramodh M likes this
G subramanyam
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 20, 2022

Thank you for the post @Pramodh M

Happy to read this stuff and I would like to connect about this.

Like • Pramodh M likes this
Yatish Madhav
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.
September 20, 2022

Thanks for this @Pramodh M 

Like • Pramodh M likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events