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

Unable to update draft for pages using REST API v2 with PUT Update Page

    XMLWordPrintable

Details

    Description

      Issue Summary

      According to REST API v2 documentation for Update Page, the following values are valid for field status in the Request Body: 'current', 'draft', 'archived', and 'deleted'.

      However, once the page is published, it's not possible to use the 'draft' value as the requests will always fail with 409 responses stating the following:

      “Version must be incremented when updating a page. Current Version: [X]. Provided version: [1]“.

      This happens independent of the version number provided for the draft, or even if no version is provided. (The value 'X' above varies depending on the actual latest version for target page)

      In parallel, when using any of the other values for status ('current', 'archived' or 'deleted') and not providing a version, it errors with a 400 response and “Must provide a version unless updating a DRAFT page.”.

      Based on the above, this API endpoint is either not working or its documentation has to be updated to reflect this particular action (drafts) is not supported.

      Steps to Reproduce

      1. Create a page and copy its id;
      2. Perform the following request via Browser Console (replace the PAGE_ID and the INSTACE_URL)

      var myHeaders = new Headers();
      myHeaders.append("X-Atlassian-Token", "no-check");
      myHeaders.append("Content-Type", "application/json");
      
      var raw = JSON.stringify({
        "id": "<PAGE_ID>",
        "status": "draft",
        "title": "Updating Page via APIv2",
        "body": {"representation": "storage","value": "<p>HELLO</p>"}
      });
      
      var requestOptions = {method:'PUT',headers:myHeaders,body:raw,  redirect:'follow'};
      
      fetch("https://<INSTANCE_URL>/wiki/api/v2/pages/<PAGE_ID>", requestOptions)
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));

      3. Check the response;

      Expected Results

      Receiving an HTTP Response 200 with the updated draft for the target page.

      Actual Results

      Receiving the following response:

      {
         errors: [{
            status: 409,
            code: "CONFLICT",
            title: "Version must be incremented when updating a page. Current Version: [1]. Provided version: [1]",
            detail: null
         }]
      }
      

      Workaround

      Currently one possible workaround is using the API v1 for Content instead with "?status=draft" in the query parameters.

      Attachments

        Issue Links

          Activity

            People

              0c24083ecc21 Miyo Imai
              6b51accb6b4d Rodrigo Bozza (Atlassian)
              Votes:
              5 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: