Rest API - Problem displaying Images from authenticated Spaces & Articles

Apologies if this is a FAQ, but a partner and I feel like we’ve been searching and trying to resolve this on our own for days with no luck.

We’ve been working on a fairly simple Ruby on Rails app that makes a request to the Confluence REST API based on the url; as long as the URL contains the Space and Article titles in a format we expect, we vomit out HTML from the API and style it appropriately. Everything is working spectacularly except images, and boyo, images are a wild ride.

There seems to be 3 combinations which impact whether or not the images are displayed:

  • If the article is public, and the image was originally attached to a public article:
    ** All images load
  • If the article is public, but the image was originally attached to a private article:
    ** The images originally attached to a public article load, but the images originally attached to a private article do not load.
  • If the article is private:
    **No images load

I can provide examples from our code, but I feel like we’re missing something very obvious in the documentation. All of our tests point toward an image inheriting the authorization requirements of the parent article, but all of our requests are authenticated… and we have no issues pulling the text from authenticated articles.

Are you using an authenticated session to retrieve the data? If so, are the image request being done as non-authenticated (ie going straight to the confluence site)? If so, you might need to proxy the image requests as your app’s user and then serve them up as anonymous - basically break the permission model (obvious warning text here - only break permissions when you need to and when you intend to - you can cause information leaks. :wink: ).

1 Like