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.

VariableValue
baseUrlhttps://your-site.atlassian.net
jiraEmailyour Atlassian account email
jiraTokenthe API token, marked as secret
projectKeya 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

HTTP
GET {{baseUrl}}/rest/api/3/myself
Accept: application/json
JavaScript
pm.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

HTTP
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=50

JQL needs URL encoding. Put the readable version in the Params tab as the value of jql and let the app encode it:

Output
project = {{projectKey}} AND statusCategory != Done ORDER BY created DESC
JavaScript
const 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

HTTP
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"]
  }
}
JavaScript
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:

HTTP
GET {{baseUrl}}/rest/api/3/issue/{{issueKey}}/transitions
JavaScript
const 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);
HTTP
POST {{baseUrl}}/rest/api/3/issue/{{issueKey}}/transitions
Content-Type: application/json

{"transition": {"id": "{{doneTransitionId}}"}}
JavaScript
pm.test('transitioned', () => pm.response.to.have.status(204));

Step 6: Errors you'll meet

StatusUsual cause
400 with errors.summary or errors.descriptionMissing field, or plain text instead of ADF
400 "issue type is invalid"The project doesn't have that issue type
404The issue doesn't exist, or your account can't see it
429Rate 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.