Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,363,501
Community Members
 
Community Events
168
Community Groups

Jira REST API v3 with OAuth 2.0 (3LO) via Google Chrome browser returns empty list []

Summary

Calling Jira REST API v3 (OAuth 2.0 (3LO)) from Google Chrome returns only an empty list. When I try the same API on Postman, it returns a list with proper contents.

Wanna know why and how to fix it.

Response via Chrome (Fail)

issues: []
maxResults: 1
startAt: 0
total: 0

Response via Postman (Success)

{
    "expand""names,schema",
    "startAt"0,
    "maxResults"1,
    "total"18,
    "issues": [
        {
            "id""10....20",
            "key""M...R-20",
            "fields": {
                "summary"".....",
                "created""2022-09-05T05:35:47.403+0000",
                "assignee": {
                    "accountId""62bb.....a1ff",
                    "displayName""Hiroshi Nishio",
                },
                "updated""2022-09-05T05:35:49.228+0000",
                "status": {
                    "name""To Do",
                    "id""10005",
                }
            }
        }
    ]
}

Source

```javascript

// Search issues in Jira with JQL
interface ParamsTypes extends Record<string, string | number | boolean> {
  startAt: number; // Default is 0
  maxResults: number; // Default is 50
  validateQuery: 'strict' | 'warn' | 'none' | 'true' | 'false'; // Default is strict
  fields: string; // Default is all fields
}

interface SearchIssuesProps {
  atlassianAccessToken: string;
  atlassianRefreshToken: string;
  atlassianCloudId: string;
  startAt: number;
  maxResults: number;
  uid: string;
}

const searchIssues = async ({
  atlassianAccessToken,
  atlassianRefreshToken,
  atlassianCloudId,
  startAt,
  maxResults,
  uid
}: SearchIssuesProps) => {
  const headers = new Headers();
  headers.append('Accept', 'application/json');
  headers.append('Authorization', 'Bearer' + atlassianAccessToken);
  const params: ParamsTypes = {
    startAt, // Default is 0
    maxResults, // Default is 50
    validateQuery: 'strict', // Default is strict
    fields: 'summary,status,assignee,creator,reporter,created,updated'
  };
  const queryString = Object.keys(params)
    .map((key) => `${key}=${encodeURIComponent(params[key])}`)
    .join('&');
  const url = `https://api.atlassian.com/ex/jira/${atlassianCloudId}/rest/api/3/search?${queryString}`;

  // Get tasks completed
  const response = await fetch(url, {
    method: 'GET',
    headers: headers
  })
    .then((res) => res.json())

  return response;
};

```

1 answer

1 accepted

3 votes
Answer accepted

Sorry for the fuss, there was no space after Bearer, so it was not authenticated. It was a completely ordinary mistake. But it would be nice if the error would tell us these things too.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events