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

Sometimes the request to create a full-width page through the API returns a 400

    XMLWordPrintable

Details

    Description

      Issue Summary

      When creating pages through the REST API, setting the full-width property will sometimes cause a 400 status response, even though the page gets created.

      Steps to Reproduce

      1. Try to create multiple pages through the API, including the property to set the page as full-width:
        "metadata": {
                "properties": {
                    "editor": {
                        "value": "v2"
                    },
                    "content-appearance-draft": {
                        "value": "full-width"
                    },
                    "content-appearance-published": {
                        "value": "full-width"
                    }
                }
            }

        Reproducible using the following fetch (just remember to change the page's title each time)

        var data = {
            "type": "page",
            "title": "Test full-width through the API 1",
            "space": {
                "key": "TS2"
            },
            "metadata": {
                "properties": {
                    "editor": {
                        "value": "v2"
                    },
                    "content-appearance-draft": {
                        "value": "full-width"
                    },
                    "content-appearance-published": {
                        "value": "full-width"
                    }
                }
            }
        }
        
        fetch("https://INSTANCE_NAME.atlassian.net/wiki/rest/api/content", {
            "headers": {
                "accept": "application/json",
                "content-type": "application/json"
            },
            "body": JSON.stringify(data),
            "method": "POST"
        })

      Expected Results

      The request should return a 200 every time

      Actual Results

      Sometimes (around 50% of the time) the request returns a 400 with the following response:

      {
          "statusCode": 400,
          "data":
          {
              "authorized": false,
              "valid": true,
              "errors": [],
              "successful": false
          },
          "message": "com.atlassian.confluence.api.service.exceptions.BadRequestException: Error occurred when updating content property content-appearance-draft. Cannot create new content property, see https://docs.atlassian.com/confluence/REST/latest/#content/{id}/property-create for usage. Property : JsonContentProperty{id='null', key='content-appearance-draft', content=ExpandedReference{idProperties={version=EmptyReference{referentClass=class com.atlassian.confluence.api.model.content.Version}, status=current, id=ContentId{id=2466186355}}, of=some(Content{id='ContentId{id=2466186355}', type=page, title='Test full-width through the API without body 1', status=current, space=ExpandedReference{idProperties={key=TS2}, of=some(Space{key='TS2', name='null'})}, history=EmptyReference{referentClass=class com.atlassian.confluence.api.model.content.History}, version=EmptyReference{referentClass=class com.atlassian.confluence.api.model.content.Version}, ancestors=null (CollapsedList), container=EmptyReference{referentClass=interface com.atlassian.confluence.api.model.content.Container}, childTypes={}})}, version=null} , isSuccessful: false, isAuthorized: false, isValid: false, hasErrors: true, Errors: \"jsonproperty.duplicate.key\""
      }

      Workaround

      Even though the 400 is thrown, the page is correctly created and it has the full-width property set, os no workaround is needed.

      Attachments

        Activity

          People

            rtalusan Ryan Talusan
            gtworkowski Guilherme T (Inactive)
            Votes:
            9 Vote for this issue
            Watchers:
            13 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: