Update child page using REST API (JavaScript)

Currently I have an HTML macro button that uses the Fetch API to create a page with a table that has content pulled from another page. I also have a function that checks if that page already exists before creating it. I pass the METHOD dynamically to the createPage function based on the boolean value returned from the function that detects if the child page already exists.

When it is a POST request, everything works as expected, but when it’s a PUT request it doesn’t update the content in the page.

I saw some other posts about passing a ContentId Field, but I’m not sure what the ContentId field would refer to and/or where to get it (tried googling, but couldn’t figure it out). There is only a Table on the child page that would be updated.

Create Page function:

let createPage = function (parentId, value, method) {
    let url = "http://exampledomain:8090/confluence/rest/api/content/"
    let username = "user123"
    let password = "pass123"

    fetch(url, {
        method: method,
        headers: {
            "Authorization": "Basic " + btoa(username + ":" + password),
            "Content-Type": "application/json"
        body: JSON.stringify({
            "type": "page",
            "title": childPageTitle,
            "ancestors": [{ "id": parentId }],
            "space": { "key": "SPACE_KEY" },
            "body": {
                "storage": {
                    "value": value,
                    "representation": "storage"

        .then(response => response.text())
        .then(result => {
        .catch(error => console.log('error', error));

Hi @Laurence ,

When using PUT /wiki/rest/api/content/{id}, the id path parameter should be the identifier of the content you’re updating.



For the identifier of the content that I’m updating, in this case the element, what would be the identifier? Would it be the ID of the HTML element or something else?

Thank you,