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

Updating a page body containing links in storage format via REST API fails

    XMLWordPrintable

Details

    Description

      Issue Summary

      If you try to update a page body that includes links to other confluence pages via REST API, this fails returning status code 400 (bad request) and below message:

      com.atlassian.confluence.api.service.exceptions.BadRequestException: Content body cannot be converted to new editor format

      Steps to Reproduce

      1. Create a page containing a link to another page
      2. GET the page content via REST API expanding the body in storage format. E.g.
        https://<NAME>.atlassian.net/wiki/rest/api/content/<PAGE-ID>?expand=body.storage
        
      1. Use the body returned from previous step to update the page sending a PUT request to
        https://<NAME>.atlassian.net/wiki/rest/api/content/<PAGE-ID>
        

      Expected Results

      The page gets successfully updated

      Actual Results

      The update fails and below error is returned:

      {{{"statusCode": 400,"data": {"authorized": false,"valid": true,"errors": [],"successful": false},"message": "com.atlassian.confluence.api.service.exceptions.BadRequestException: Content body cannot be converted to new editor format"}}}
      

      Workaround

      The root-cause for this issue seems to be that for some reason the tag ri:space-key is expected to be found even if:

      • It is not returned in the storage representation of the link when sending the GET request (step 2):
        <ac:link><ri:page ri:content-title=\"NEW TEST\" ri:version-at-save=\"6\" /></ac:link>
        
      • It is not mandatory and not even needed most of the time

       

      Indeed, even if this is not even documented for the links storage format in Confluence Storage Format - Links (for Server but still applicable), it can be found in the examples on the same page:

      AN EXAMPLE OF DIFFERENT LINK BODIES 

      <ac:link>
       <!-- Any resource identifier --> 
       <ri:page ri:content-title="Home" ri:space-key="SANDBOX" /> 
       <ac:link-body>Some <strong>Rich</strong> Text</ac:link-body>
       </ac:link>
       ...
      

       

      Therefore, by using below format you should manage to update the page:

      <ac:link><ri:page ri:content-title=\"NEW TEST\" ri:space-key=\"<SPACE-KEY>\" /></ac:link>
      

       

      You can follow the below thread on the developers community for further updates/discussions on this:

      Attachments

        Issue Links

          Activity

            People

              cd055fd0d3e8 Lucas Pan
              dbonotto Dario B
              Votes:
              58 Vote for this issue
              Watchers:
              43 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: