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('&');
// Get tasks completed
const response = await fetch(url, {
method: 'GET',
headers: headers
})
.then((res) => res.json())
return response;
};
```
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.