Attachments broken after using copy single page API

We are experiencing an issue with the copy single page API. Our code used to work, but Atlassian must have changed something on their side that broke it.

We make two POST requests against /rest/api/content/{id}/copy.

Request 1: We’re copying source page 1, putting it under an existing parent page, and supplying a modified body. The referenced attachment does not yet exist. It will be copied in the second call.

POST /rest/api/content/{source-page-1-id}/copy

{
   "copyAttachments": true,
   "copyPermissions": false,
   "copyProperties": false,
   "copyLabels": true,
   "copyCustomContents": false,
   "destination": {
     "type": "parent_page",
     "value": "{parent-page-id}"
   },
   "pageTitle": "Target Page",
   "body": {
      "storage": {
       "representation": "storage",
       "value": "<ac:image><ri:attachment ri:filename=\"image.jpg\" ri:version-at-save=\"1\" /></ac:image>"
     }
   }
}

Request 2: We’re copying source page 2 to the existing target page, again supplying a modified body. Source page 2 contains the referenced attachment.

POST /rest/api/content/{source-page-2-id}/copy

{
   "copyAttachments": true,
   "copyPermissions": false,
   "copyProperties": false,
   "copyLabels": false,
   "copyCustomContents": false,
   "destination": {
     "type": "existing_page",
     "value": "<target-page-id>"
   },
   "pageTitle": "Target Page",
   "body": {
      "storage": {
       "representation": "storage",
       "value": "<ac:image><ri:attachment ri:filename=\"image.jpg\" ri:version-at-save=\"1\" /></ac:image>"
     }
   }
}

Everything seems to work: the attachment is there, the storage format looks right, the image even shows up in the export view (e.g. in PDF exports). However, the Confluence page view in the browser refuses to show the image. Instead it shows a gray placeholder box.

2 Likes

Hi @maximilian,

Thank you for flagging this.

We can confirm that something changed on our end and that caused the problem that you are reporting this.

I’ll add an update here as soon as I know more and when the fix is available.

Thank you again,
Caterina

1 Like

Hey,
a quick FYI, we’ve also reported this bug and it’s been confirmed. You can watch and vote for it [CONFCLOUD-73020] Copying a page with body causes the image not be shown on the page - Create and track feature requests for Atlassian products.
Cheers

2 Likes

That’s correct @ChupaCabra. Thanks for posting the link.

Let me also share that we have identified a workaround and I’ve just posted it on the ticket description itself.

1 Like