Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-57573

After creating page with REST and attachment, attachment is lost

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • None
    • 6.12.2
    • None

    Description

      Summary

      When creating a page via a REST call, if the storage format has an attachment, then that attachment is lost on subsequent edits of the page via the UI, even though it displays correctly on first view.

      Steps to Reproduce

      1. Create a page via REST call with an embedded attachment (here, an image)
        create page
        curl -s -u admin:admin -H 'Content-Type: application/json' -d '{"type":"page","title":"my page","space":{"key":"KEY"},"body":{"storage":{"value":"<p>This is a new page</p><p><ac:image ac:thumbnail=\"true\" ac:height=\"250\"><ri:attachment ri:filename=\"meeple.png\" /></ac:image></p>","representation":"storage"}}}' http://localhost:8090/rest/api/content/
        
      1. Upload the attachment (change page id as required)
        upload attachment
        curl -s -u admin:admin -H "X-Atlassian-Token: no-check" -F "file=@meeple.png" -F "comment=this is my meeple" "http://localhost:8090/rest/api/content/327714/child/attachment"
      1. Edit the page through the browser to make a change.

      Expected Results

      The image stays attached to the page and displays correctly.

      Actual Results

      The image appears as a Broken Attachment both in view and edit

      actual.png

      Workaround

      Create the page with dummy content, upload the attachment and then update the page with the correct content.

      create page
      curl -s -u admin:admin -H 'Content-Type: application/json' -d '{"type":"page","title":"my page","space":{"key":"KEY"},"body":{"storage":{"value":"<p>This is a page holder</p>","representation":"storage"}}}' http://localhost:8090/rest/api/content/
      
      upload attachment
      curl -s -u admin:admin -H "X-Atlassian-Token: no-check" -F "file=@meeple.png" -F "comment=this is my meeple" "http://localhost:8090/rest/api/content/327714/child/attachment"
      
      update page content
      curl -s -u admin:admin -X PUT -H 'Content-Type: application/json' -d '{"id":"327714","type":"page","title":"my page",
      "body":{"storage":{"value":
      "<p>This is a new page</p><p><ac:image ac:thumbnail=\"true\" ac:height=\"250\"><ri:attachment ri:filename=\"meeple.png\" /></ac:image></p>","representation":"storage"}},"version":{"number":2}}' http://localhost:8090/rest/api/content/327714
      

      Attachments

        1. actual.png
          actual.png
          63 kB
        2. expected.png
          expected.png
          87 kB
        3. meeple.png
          meeple.png
          20 kB
        4. step3.png
          step3.png
          50 kB

        Activity

          People

            Unassigned Unassigned
            jrichards@atlassian.com James Richards
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: