You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
This is more of a technical question but the Developer Community has been pretty unhelpful thus far.
I want to make a GET request to the JIRA REST API from a Confluence Cloud macro I'm developing for my internship. Because Atlassian doesn't support cross-platform requests natively, I have to make the request outside of routes/index.js and instead in a script tag of the .hbs file in my views folder. I'm prototyping so I'm only using basic auth as detailed in the documentation. When I test it outside my app with the command line with curl and also straight up in my browser while I'm logged into Confluence I'm able to get the issues I want to return. But... when I attempt to make the request form within the .hbs file an OPTIONS request gets made instead and the Authentication header with the username and password that I set is not there...
This is the code that I'm using....
let url = 'https://site.atlassian.net/rest/api/3/search'
let h = new Headers(); h.append('Accept', 'application/json');
let encoded = window.btoa('USERNAME:APITOKEN'); let auth = "Basic " + encoded;
h.append('Authorization', auth)
let req = new Request(url, { method: 'GET', headers: h })
fetch(req)
.then( (res) => {
return res.json().then( (data) => {
if(res.ok) { return data; } else { return Promise.reject({status: res.status, data}); } }); }) .then((data) => { console.log(data); })
Does anyone know why this is happening?
The url you use should have `https` instead of `http`. Hope that helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.