Explore the JIRA Server REST API using Postman
Importance Jira Automation
Automation in Jira is essential because it reduces time, improves productivity, and fosters cooperation among team members. This blog will show you how to automate different activities in Jira. It will also reduce your workload and provide you with a detailed analysis. This will allow you to concentrate on more important aspects.
“Keep your eyes on the most important things. Let automation do all the work .”
What’s JIRA?
JIRA is a Software Test/Bug Tracking Tool that was developed by Atlassian, an Australian company. Jira is gaining popularity with more than 180,000 people in 190 nations. Jira is a bug-tracking tool that allows agile project management.
Jira Remote Access APIs allow you to connect to Jira server applications. For basic capabilities such as issues and workflows the Jira Server platform offers a REST API. You can also create any other interface.
Projects – It’s used to effectively manage defects.
Issue is used to track down and manage defects/issues.
Workflow: Processes Issue/Defect lifecycle.
Search – Find quickly. Jira allows us to see what happened in earlier versions as well as the defects that occurred in those projects.
Dashboards – A dashboard is what you see when you log into Jira to keep track the issues and assignments you are working on.
What is Automation?
You can focus on the important task of Eliminating the requirement for Manual, Repeatable Chores as well as ensuring it adheres to strict standards. It checks for errors, bugs, and other problems that might arise while creating a product.
It works Efficiently and quickly which can dramatically reduce the time required to evaluate products. This will allow developers and production managers to spend more time on other elements of the project. It can significantly improve productivity.
Automating Jira
You can extend Jira’s capabilities to meet your business requirements by using Jira APIs REST APIs or Java APIs. So, are you ready to dive deeper into Jira APIs? Let’s get started if that’s you. This blog will give you information about Jira as well as show you how you can make the most of its amazing capabilities.
This RESTAP Documentation can be used to Create Add-ons For JIRA. You can integrate JIRA with other applications or create script interactions with JIRA.
We must also ensure that we use the JIRA server. Therefore, JIRA Server HTTP0_ must be used and not the cloud. Refer to the following link as we will be connecting to our JIRA server on a local machine. You can have fun with this connection by hitting the links, and then getting the response loaded with your local host software.
URI Structure
JIRA’s RESTAPIs allow access to data entities (resources) via URI paths. Your application will send an HTTP request to a REST API and then parse the returned response. JIRA REST API uses JSON for its communication format. It also uses the standard HTTP methods such as GET, PUT and DELETE.
http://host:port/context/rest/api-name/api-version/resource-name
You can verify the response code you received back after hitting each API. Below are a few that are widely used.
Code and description
- 1xx Informational: Your request has been received and the process is continuing.
- 2xx : Success is when the action was received, understood and accepted.
- 3xx Redirection: Additional action is required to complete the request.
- 4xx – Client Error : The request has an incorrect syntax or cannot been fulfilled.
- 5xx – Server Error : An apparently valid request was not fulfilled by the server.
JSON Response
- Request successful:
{
“success”: true,
“payload”: {
* Application-specific data would be found here. */
}
}
- Failed request
{
“success”: false,
“payload”: {
* Application-specific data would be found here. */
},
“error”: {
“code”: 123,
“message”: “An error occurred!”
}
}
Creating new sessions and Storing the key
Step 1
Open postman, and then hit the URL.
Step 2
Select “raw” from the Body section. Then, select JSON (application/JSON).
Enter your username and password in the format below
“username”: “myuser”, “password”: “mypassword”
Step 3
You will need to verify the creation of a session.
{
“session”:
{
“name”:”example.cookie.name”,
“value”:”6E3487971234567896704A9EB4AE501F”
}
}
Final: Congratulations! You successfully logged into the application and Created an Session.
Now, let’s use the session cookie to perform operations on our account. Let’s take a look at some of the most important operations that JIRA can perform with the REST APIs.
Creating Issue
From a JSON representation, creates an issue or sub-task. The link contains all data and steps required to create a new problem. The Atlassian Doctation provides the data.
To create an issue, we must use a POST request. The link to use is /rest/api/2/issue.
Open postman to enter the URL.
http://localhost:8000/rest/api/2/issue
Step 2
Choose the ” POST” option
Step 3
Go under the Body section, select “raw” and select JSON(application/JSON) in place of Text
{
“fields:
{
“project”:
{
“key”: “RES”//projectKey
},
“summary”: “Occurred Defect”,
“description: This is my first bug”
“issuetype”: {
“name”: “Bug”
}
}
}
Step 4
Enter the following key and value into the Headers tab: Cookie = “yourSessionKey” JSESSIONID= “yourSessionKey”.
Step 5:
Verify you receive the reply in such a way that it is clear and concise:
{
“id”: “1001”,
“key”: “RES-1”,
“self”: “http://localhost:8000/rest/api/2/issue/1001”
}
Conclusion Congratulations! You have created your first bug using REST API.
Delete Issue
To delete an issue, use the Delete API
Step 1
Enter the URL in Postman.
http://localhost:8000 /rest/api/2/issue/issueIdOrKey
Step 2
Select the ” DELETE method
Step 3
Enter the following key and value into the Headers tab: Cookie = “yourSessionKey” JSESSIONID= “Cookie”.
Step 4
Verify that you got the correct Status code: 204
Conclusion Congratulations! You just solved an issue using Rest API.
Notable: We barely touch the JIRA Dashboard and our API request works for us.
Add Comment
The Add Comment API allows you to make a comment on an issue.
Step 1
Enter the URL in Postman.
http://localhost:8000/rest/api/2/issue/issueIdOrKey/comment
Step 2
Choose the “POST” method
Step 3
Go under the Body section, select “raw” and select JSON(application/JSON) in place of Text
Step 4
Enter the value below
{
“body”:
“visibility”: {
“type”: “role”,
“value”: “Administrators”
}
}
Step 5:
Navigate to the Headers tab and enter “Cookie” as the key.
Step 6
Verify that we received the correct Status code: “201”. This indicates that the comment was successfully added.
Final: Congratulations! You have successfully added a new comment using the REST API.
Comment
Updates an existing comment by using its JSON representation
Step 1
Enter the URL in Postman.
http://localhost:8000/rest/api/2/issue/issueIdOrKey/comment/id
Notice: The comment ID will be generated from the JSON response received.
Step 2
Choose the “PUT” method
Step 3
Go under the Body section, select “raw” and select JSON(application/JSON) in place of Text
Step 4
Enter the value below
{
“body”: This is my updated comment from RESTAPI.
“visibility”: {
“type”: “role”,
“value”: “Administrators”
}
}
Step 5:
Enter the following key and value into the Headers tab: Cookie = “yourSessionKey”
Step 6
Verify that we have received the correct Status code: “200”. This indicates that the comment was successfully updated.
Conclusion Congratulations! You have successfully updated your comment using the REST API.
Conclusion : Now we are familiar with JIRA. We can automate it using REST APIs to execute POST, DELETE and GET operations. The basics of JSON Response Structure. You also learned the Key Features that Jira has that make it so popular with developers. You also learned the steps for working with Jira APIs.