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.
Hello everyone
I want to connect to Confluence space using API Token
I want to display data on my website using pure JS
First of all, I am stuck on generating proper access token as I am trying this method to work
I got token from my customer which is 24 characters long
and it doesn't work using method below,
Is there a way to generate API Token for Confluence only?
fetch('https://your-domain.atlassian.net/wiki/rest/api/content', {
method: 'GET',
headers: {
'Authorization': 'Bearer <access_token>',
'Accept': 'application/json' } }
).then(response => {
console.log( `Response: ${response.status} ${response.statusText}` );
return response.text(); }
).then(text => console.log(text))
.catch(err => console.error(err));
Welcome to the community 🙂
You need Email and Token for Authentication
Please find the ref here for converting both email and token to autothirzed header
Thanks,
Pramodh
Hi @Wojciech Gwardjak Welcome to the Atlassian Community!
In your Authorization header, try replacing Bearer with Basic followed by the encoded string and see if that works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello, thank you! It works but now I cannot get the page content body....
How to pull this data?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you happen to know maybe how to make page content body visible?
In each page I receive request for I have blank space in body, while there is certainly content on my Confluence for each of them
Thank you!
The same occurs using space request, it pulls the pages but without body, I cannot pull the content :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can add below parameter to read content of a page with its body expanded.
expand=body.storage
example - https://yoursite.atlassian.net/wiki/rest/api/content/12345678?expand=body.storage
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Kishan Sharma
Actually it works!
But now the problem is....
While pulling the data with postman it sends object with the data and receives it well.
While doing the same on my page using JS function it responds with CORS error or response 0 (while mode: no-cors is on)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To call protected APIs from external systems you can add the X-Atlassian-Token
header to each request, setting the value to no-check
. Adding this header to a request bypasses the server-side XSRF check and allows the request to be fulfilled.
-H "X-Atlassian-Token: no-check"
You can try adding the above header in your request and see if that works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Following to @Kishan Sharma Answer thread here
Please find the reference below
https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#special-request-headers
Thanks,
Pramodh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for response @Kishan Sharma @Pramodh M
Unfortunately it still pulls the same response 0 :(
I use the same method for my page and the postman as well
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So you are now trying to embed the confluence page into your website ? If yes, I would suggest going through this thread for more information.
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.