I have been trying to use the REST API for the last few hours, but has not been able to find a solution, even though several people have posted similar questions. I think it might be because of the setup.
Windows 10
Brave Browser (Chrominum based)
I have a simple html-file with the following content:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Jira Sprint progress</title>
<script src="js/main.js"></script>
</head>
<body>
</body>
</html>
Which links to a js file with the following content:
const username = 'xxx';
const password = 'yyy';
async function getAllSprints(){
let data = await fetch('https://{domain}.atlassian.net/rest/agile/1.0/board/1/sprint', {
method: 'GET',
headers: {
'Authorization': 'Basic ' + btoa(username + ":" + password),
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
}
});
return data;
}
I have removed the username, password and domain, but I am sure that all are typed out correctly, as they are copied directly from Postman, where I get a valid json response.
When I run the above code in the browser however, I get the following error message:
Access to XMLHttpRequest at 'https://{domain}.atlassian.net/rest/agile/1.0/board/1/sprint' from origin 'http://localhost:63342' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
GET https://{domain}.atlassian.net/rest/agile/1.0/board/1/sprint net::ERR_FAILED
Can someone tell me what I am doing wrong, or if what I am trying to do is invalid?
I am basically trying to make a small application that visualizes the sprint progress, I want it to run on a small computer in our office, so that everyone can see how we are doing. I therefore just wants it to run locally. But I don't know if that is impossible - it seems like it atm :/