Uploaded image for project: 'Confluence Cloud'
  1. Confluence Cloud
  2. CONFCLOUD-70325

Can't publish edits to pages copied with the API

    XMLWordPrintable

Details

    Description

      Issue Summary

      When using Confluence's REST API to copy pages, it won't be possible to publish edits to them.
      It's happening to either single pages or to pages copied in bulk using the /rest/api/content/PAGE_ID/copy endpoint.

      Steps to Reproduce

      1. create some pages in the new editor
      2. use the copy page api to copy the pages to another space
      3. Try to edit and publish some of the copies

      Expected Results

      It should be possible to publish edits to the copies

      Actual Results

      The following error is shown:

      This content cannot be accessed.

      Your session may have expired. You'll need to log in again or switch to another account to keep working.
      Log in or switch to another account

      The request responds with a 404:

      Request URL: https://INSTANCE.atlassian.net/wiki/rest/api/content/PAGE_ID/?status=draft&action=publish
      Request Method: PUT
      Status Code: 404 
      
      Payload:
      {
          "id": "33687092",
          "type": "page",
          "title": "Page7",
          "space":
          {
              "key": "LSCA"
          },
          "body":
          {
              "editor":
              {
                  "value": "{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"type\":\"text\",\"text\":\"Test page\"}]}],\"version\":1}",
                  "representation": "atlas_doc_format",
                  "content":
                  {
                      "id": "33687092"
                  }
              }
          },
          "status": "current",
          "version":
          {
              "number": 2,
              "message": "",
              "minorEdit": false,
              "syncRev": "0.1J5gwnHlridgfWJNgrBCmw.0"
          }
      }
      
      Response:
      {
          "statusCode": 404,
          "data":
          {
              "authorized": false,
              "valid": true,
              "errors": [],
              "successful": false
          },
          "message": "com.atlassian.confluence.api.service.exceptions.NotFoundException: null"
      }

      Notes

      • This also happens when copying a single page using the same endpoint

      Workaround

      Option A:

      1. Edit the page
      2. Click on ••• and select View Changes
      3. Close the changes dialog and Publish the page

      Option B:

      1. Create a new bookmark to any page in your browser.
      2. Edit the bookmark: change name to 'Fix page' (or any other suitable name) and change address to the following:
        javascript:fetch('/wiki/rest/tinymce/1/content/' + /pages(\/[\w-]+)?\/(\d+)/g.exec(location.href)[2] + '/draft/diff').then(() => console.log('Page fixed')).catch(() => console.log('Error'));
        
      3. Save the bookmark. For convenience move it to some easily accessible place (for example Bookmarks Bar in Chrome).
      4. Navigate to the page that you can't edit and invoke the added bookmark. You should now be able to edit the page.

      Option C:

      1. Navigate to the page that you can't edit and open Developer Tools (Chrome), Web Inspector (Safari) or the alternative in your browser.
      2. In the Developer Tools open Console.
      3. Paste the following code to the console and press Enter:
        fetch('/wiki/rest/tinymce/1/content/' + /pages(\/[\w-]+)?\/(\d+)/g.exec(location.href)[2] + '/draft/diff').then(() => console.log('Page fixed')).catch(() => console.log('Error'));
        
      4. You should see the "Page fixed" message, and after that you should be able to edit the page.

      Attachments

        Issue Links

          Activity

            People

              rtoropov@atlassian.com Roman Toropov
              gtworkowski Guilherme T (Inactive)
              Votes:
              58 Vote for this issue
              Watchers:
              57 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: