Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can't display image in page properties macro when updated via API

Alvise Z_ January 28, 2021

We've been using Confluence API to upload images in a specific section of our wiki pages, however these pictures are now not displaying correctly inside the macro (a page properties one, with a specific ID).

The API request goes through and succeeds; however in the attachments section we cannot see the preview of such images, we can only download them. The downloaded pictures correspond perfectly with what we expect to see in the page. 

However, they seem not be loaded correctly in the page:

https://ibb.co/t21DLS6

If we try to upload the same picture "manually" inside the macro and publish the page, it all works fine. Whenever we try to update it however, it will go back to the "failed to load mode". 
Other pictures that we uploaded manually once can be previewed just fine.

 

Some specifications of the POST API call we perform:

```

headers = {"X-Atlassian-Token": "no-check"}
"minorEdit": True,
"type": "attachment"
"comment": timestamp
"url": https://xxx.atlassian.net/wiki/rest/api/content/<pageID>/child/attachment/<attachmentID>/data

"file": @file
```

We believe the problem is the `mediaType` the API recognizes the PNG file to be, which is oddly: `application/octet-stream`, as we see when we issue a GET call to get the list of attachments. However `mediaTypeDescription` is correctly `PNG Image`.
We couldn't find any way to force `mediaTyppe` to be `image/PNG` in the API documentation.

Any help would be appreciated, thanks.

1 answer

0 votes
Diego
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 24, 2021

Hello there @Alvise Z_ !

Going straight to the point, I tried to replicate the behavior but was unable to.

Even though our community is filled with capable members, I firmly believe that your situation will be best served by our sister, the Developer Community!

Maybe take a look and share your situation with our experts over there:

Let us hear from you!

Alvise Z_ February 24, 2021

Hi Diego, will do.

Thank you for the suggestion.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events