How to test the Jira REST API
Teams automate Jira constantly: create an issue from an alert, move it when a deploy ships, pull a list of open bugs into a report. All of that goes through the Jira Cloud REST API. Setting it up in an API client first saves a lot of guesswork, especially around JQL, issue fields and the rich-text format Jira uses for descriptions.
Step 1: API token and environment
Create a token at id.atlassian.com → Security → API tokens.
| Variable | Value |
|---|---|
baseUrl | https://your-site.atlassian.net |
jiraEmail | your Atlassian account email |
jiraToken | the API token, marked as secret |
projectKey | a test project, such as TEST |
On the collection's Authorization tab, choose Basic auth with username {{jiraEmail}} and password {{jiraToken}}.
Step 2: Check the connection
GET {{baseUrl}}/rest/api/3/myself
Accept: application/jsonpm.test('authenticated', () => {
pm.response.to.have.status(200);
pm.expect(pm.response.json().emailAddress).to.equal(pm.environment.get('jiraEmail'));
});A 401 means the email or token is wrong. A 403 usually means the account can't use the API on this site.
Step 3: Search with JQL
GET {{baseUrl}}/rest/api/3/search/jql?jql=project%20%3D%20{{projectKey}}%20AND%20statusCategory%20!%3D%20Done%20ORDER%20BY%20created%20DESC&fields=summary,status,assignee&maxResults=50JQL needs URL encoding. Put the readable version in the Params tab as the value of jql and let the app encode it:
project = {{projectKey}} AND statusCategory != Done ORDER BY created DESCconst body = pm.response.json();
pm.test('returns issues', () => pm.expect(body.issues).to.be.an('array'));
pm.environment.set('nextPageToken', body.nextPageToken || '');Results are paged: when there are more, the response has a nextPageToken. Pass it as the nextPageToken query parameter to get the next page.
Step 4: Create an issue
POST {{baseUrl}}/rest/api/3/issue
Content-Type: application/json
{
"fields": {
"project": {"key": "{{projectKey}}"},
"issuetype": {"name": "Task"},
"summary": "API test issue {{$timestamp}}",
"description": {
"type": "doc",
"version": 1,
"content": [
{"type": "paragraph", "content": [{"type": "text", "text": "Created by an API test. Safe to delete."}]}
]
},
"labels": ["api-test"]
}
}pm.test('issue created', () => pm.response.to.have.status(201));
pm.environment.set('issueKey', pm.response.json().key);The description is Atlassian Document Format, a JSON tree of paragraphs and text nodes. Plain text there gets a 400. That's the most common surprise in API v3; v2 still takes plain text.
Step 5: Move it through the workflow
Transitions have IDs that differ per workflow, so look them up first:
GET {{baseUrl}}/rest/api/3/issue/{{issueKey}}/transitionsconst done = pm.response.json().transitions.find((t) => t.to.statusCategory.key === 'done');
pm.test('has a transition to done', () => pm.expect(done).to.not.be.undefined);
pm.environment.set('doneTransitionId', done.id);POST {{baseUrl}}/rest/api/3/issue/{{issueKey}}/transitions
Content-Type: application/json
{"transition": {"id": "{{doneTransitionId}}"}}pm.test('transitioned', () => pm.response.to.have.status(204));Step 6: Errors you'll meet
| Status | Usual cause |
|---|---|
400 with errors.summary or errors.description | Missing field, or plain text instead of ADF |
400 "issue type is invalid" | The project doesn't have that issue type |
404 | The issue doesn't exist, or your account can't see it |
429 | Rate limited; wait for Retry-After |
Jira lists field errors by name in an errors object, so a test can check exactly which field was rejected.
Already using Jira with your API tests?
Requestarium can file a Jira issue automatically when a collection run fails in CI, and comment on it when it fails again. See File Jira issues automatically when API tests fail.