Get Confluence page via REST API and embed it (incl. images and links) on a 3rd party website

Hello there!

My company and I are working on a small integration project for a client. They have their whole knowledge base in Confluence Data Server v.7.3.18, and want to have content from their pages displayed on pages from our website.

My plan is to use the Confluence REST API to fetch the Confluence page in a javascript script - the API on the Confluence Data Server allows me to grab the body of a page in “view” format and simply display it on the page.

But I keep running into all sorts of issues - CORS, Authentication, how to actually display the image etc.

For example, in order to do preliminary testing of this (i.e. until we get access to our client’s Confluence), I am trying to use our Confluence Cloud REST API - which has 2 versions.
Version 1 seems to be very similar, if not the same, as the API version on Confluence Data Server.
But I cannot make requests from my website through JS’s fetch because of CORS errors, and I cannot set Confluence Cloud to whitelist the domain I am trying to call from.
Not to mention that when using v2, neither body format storage nor atlas_doc_format do what I want them to, unless I heavily modify the result or straight up generate HTML based on the JSON atlas_doc_format. But this is irrelevant as I believe the Confluence Data Server API supports grabbing the body in “view” format.

Another example of an issue I ran into is that when trying to simply put in the body of a Confluence page (retrieved through Postman) - incl. images - on our website using plain old jQuery, if I am not authenticated on Confluence in the same browser, I cannot see the content. I have found numerous questions about this but I seem to have gotten more confused as to how to handle the authentication.
I am not building an app, so OAuth2.0 doesn’t seem to be the way to go for me here, but Basic Auth also doesn’t seem to do enough??? I simply want to fetch the Confluence page and put it on my page using javascript.

All this being said, maybe there’s some things I am missing and/or misunderstanding? Maybe there are better alternatives or approaches that I haven’t been able to figure out yet?
Is there any advice anyone can give as to how to go about this? Has there really been nobody that wants to do exactly what I am trying to do, so I can find a good example of how to do it? It seems so simple, but yet so complicated. I would’ve expected having access to e.g. viewing images on a page when calling an API endpoint was a minimum thing to allow?

Maybe some new angles, some options I haven’t considered yet?

Please help :sweat_smile:

1 Like