Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a page over REST breaks included attachments

Jens Iwanenko
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 11, 2019

Hi all,

So, I wrote a user macro that copies the contents of a page to another content entity over REST. If the page has attachments, the macro then calls itself with a URL parameter and copies the attachments over to the new content entity using the attachmentManager. The page shows fine, images and everything are there and "Show storage format" shows a correctly formatted page. However, when I edit the page, all the attachments break and the "unknown attachment" image is inserted instead. The source code plugin shows a different code than the "Show storage format" option. If I save the new content entity, the image brakes completely and the "unknown attachment" image is hard saved into the entity as an image.

"body.storage.value" contains the correct markup, so do the other "body" formats over REST.

Reverting to the entity's v.1 after breaking the images restores the original images and makes the page editable without breaking the images again. I tried increasing the version of the entity by 1 via rest, but without any changes to the body it doesn't seem to register. When I open the entity in the editor and click 'Revert to last published version', the images are restored and the entity can be edited as if nothing happened. Funnily, when I call convertToHistoricalVersion on the entity, it breaks the images like when I'd go and edit and save the entity as described above.

Am I missing something? Does Confluence have a cache somewhere that notices missing attachments when creating content? I need the copied content to be editable by ordinary users straight away. I can't expect my users to edit and discard changes of the new content before doing actual changes.

Best
Jens

PS: This is on Server 6.14.3.

1 answer

1 accepted

0 votes
Answer accepted
Jens Iwanenko
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2019

I would like to answer my own question:

I investigated the copy space plugin, because it does something similar to what I was trying to do, and that plugin calls saveContentEntity after making changes (like copying attachments or setting the original author). Calling saveContentEntity on the pageManager in my macro after copying over the attachments seems to fix the problem.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events