Updating a Table in a confluence page using Rest API call

Hi All,
Can anyone please provide me any document where it is shown how to use postman to query using rest API call to confluence page to get a table content and also update the table with a new row appended?
I need to update a table in confluence page dynamically from Jenkins pipeline groovy code using rest API call.
Thanks

I am also interested in doing the same if you were able to solve or if anyone else can provide help.

Welcome to the Atlassian developer community @JackLoCasto,

The original post did not specify Server/DC or Cloud. Which are you working from? And, do you have the same client constraints with Jenkins & Groovy?

Thank you for the response! I am specifically working with cloud. I do not have the same constraints. I am simply making requests from a python script to try to update a couple of tables in one of our pages.

My first thought was to make a GET request to get the contents of the page and update the table contents through the structure that python creates from that call. Then once I make my edits make a PUT request to update the page. Currently I am having trouble finding the table contents. I assume it has to do with my lack of knowledge with pagination. My next step was to work with the expand, limit, and start query parameters.

@JackLoCasto,

OK, we’ll hope the original poster can benefit from this too.

The most direct way to your page is to get page by id using GET /wiki/api/v2/pages/{id}. With only 1 resource at a time, you won’t have any pagination.

However, there is some trick to getting into the content and finding a specific table. You’ll want to learn a bit about the Atlassian Document Format (ADF) and the table node in particular. Rather than try to walk the ADF object tree with Python, I would probably use a query language like JMESPath via jmespath.py.

Once you have made the appropriate changes, you update page using PUT /wiki/api/v2/pages/{id}.

I’ve left a lot of details as “exercise for the reader” but I hope that rough sketch gets you going in the right direction. Or, if you get stuck, you’re welcome to ask more questions.

@ibuchanan Thank You! This is very helpful! I will definitely reach back out if I have any further questions!

@ibuchanan I am having trouble using the v2 API but v1 seems to work for me per the documentation here: https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content/#api-wiki-rest-api-content-id-get.

My issue now is that I do not see the content of the page I am looking for. Here is what I am receiving when I make my GET request:

{
    "_expandable": {
        "ancestors": "",
        "body": "",
        "children": "/rest/api/content/9207898/child",
        "container": "/rest/api/space/MFOS",
        "descendants": "/rest/api/content/9207898/descendant",
        "metadata": "",
        "operations": "",
        "restrictions": "/rest/api/content/9207898/restriction/byOperation"
    },
    "_links": {
        "base": "<our base url>",
        "collection": "/rest/api/content",
        "context": "/confluence",
        "edit": "/pages/resumedraft.action?draftId=9207898&draftShareId=f544e174-ad1c-42df-b915-dfe1a94a6bad",
        "self": "<our base url>/rest/api/content/9207898",
        "tinyui": "/x/WoCM",
        "webui": "/display/MFOS/System+Status"
    },
    "extensions": {
        "position": 7
    },
    "history": {
        "_expandable": {
            "contributors": "",
            "lastUpdated": "",
            "nextVersion": "",
            "previousVersion": ""
        },
        "_links": {
            "self": "<our base url>/rest/api/content/9207898/history"
        },
        "createdBy": {
            "_expandable": {
                "status": ""
            },
            "_links": {
                "self": "<our base url>/rest/api/user?key=8a808414915bdff601919978efbd0000"
            },
            "displayName": "<name>",
            "profilePicture": {
                "height": 48,
                "isDefault": true,
                "path": "/confluence/images/icons/profilepics/default.svg",
                "width": 48
            },
            "type": "known",
            "userKey": "<my user key>",
            "username": "<my username>"
        },
        "createdDate": "2024-09-03T09:20:59.628-04:00",
        "latest": true
    },
    "id": "9207898",
    "position": 7,
    "space": {
        "_expandable": {
            "description": "",
            "homepage": "/rest/api/content/688129",
            "icon": "",
            "metadata": "",
            "retentionPolicy": ""
        },
        "_links": {
            "self": "<base url>/rest/api/space/MFOS",
            "webui": "/display/MFOS"
        },
        "id": 655361,
        "key": "MFOS",
        "name": "MFoS",
        "status": "current",
        "type": "global"
    },
    "status": "current",
    "title": "System Status",
    "type": "page",
    "version": {
        "_expandable": {
            "content": "/rest/api/content/9207898"
        },
        "_links": {
            "self": "<base url>/rest/experimental/content/9207898/version/2"
        },
        "by": {
            "_expandable": {
                "status": ""
            },
            "_links": {
                "self": "<base url>/rest/api/user?key=8a808414915bdff601919978efbd0000"
            },
            "displayName": "<name>",
            "profilePicture": {
                "height": 48,
                "isDefault": true,
                "path": "/confluence/images/icons/profilepics/default.svg",
                "width": 48
            },
            "type": "known",
            "userKey": "<user key>",
            "username": "<username>"
        },
        "hidden": false,
        "message": "",
        "minorEdit": false,
        "number": 2,
        "when": "2024-09-03T11:18:34.133-04:00"
    }
}

I then tried adding the following expand query ?expand=version.content where I received the below:

{
    "_expandable": {
        "ancestors": "",
        "body": "",
        "children": "/rest/api/content/9207898/child",
        "container": "/rest/api/space/MFOS",
        "descendants": "/rest/api/content/9207898/descendant",
        "history": "/rest/api/content/9207898/history",
        "metadata": "",
        "operations": "",
        "restrictions": "/rest/api/content/9207898/restriction/byOperation",
        "space": "/rest/api/space/MFOS"
    },
    "_links": {
        "base": <our base url>,
        "collection": "/rest/api/content",
        "context": "/confluence",
        "edit": "/pages/resumedraft.action?draftId=9207898&draftShareId=f544e174-ad1c-42df-b915-dfe1a94a6bad",
        "self": "<our base url>/rest/api/content/9207898",
        "tinyui": "/x/WoCM",
        "webui": "/display/MFOS/System+Status"
    },
    "extensions": {
        "position": 7
    },
    "id": "9207898",
    "position": 7,
    "status": "current",
    "title": "System Status",
    "type": "page",
    "version": {
        "_links": {
            "self": "<our base url>/rest/experimental/content/9207898/version/2"
        },
        "by": {
            "_expandable": {
                "status": ""
            },
            "_links": {
                "self": "https://mfos.services.nres.navy.mil/confluence/rest/api/user?key=8a808414915bdff601919978efbd0000"
            },
            "displayName": "<name>",
            "profilePicture": {
                "height": 48,
                "isDefault": true,
                "path": "/confluence/images/icons/profilepics/default.svg",
                "width": 48
            },
            "type": "known",
            "userKey": "<my user key>",
            "username": "<my username>"
        },
        "content": {
            "_expandable": {
                "ancestors": "",
                "body": "",
                "children": "/rest/api/content/9207898/child",
                "container": "/rest/api/space/MFOS",
                "descendants": "/rest/api/content/9207898/descendant",
                "history": "/rest/api/content/9207898/history",
                "metadata": "",
                "operations": "",
                "restrictions": "/rest/api/content/9207898/restriction/byOperation",
                "space": "/rest/api/space/MFOS",
                "version": ""
            },
            "_links": {
                "edit": "/pages/resumedraft.action?draftId=9207898&draftShareId=f544e174-ad1c-42df-b915-dfe1a94a6bad",
                "self": "<our base url>/rest/api/content/9207898",
                "tinyui": "/x/WoCM",
                "webui": "/display/MFOS/System+Status"
            },
            "extensions": {
                "position": 7
            },
            "id": "9207898",
            "position": 7,
            "status": "current",
            "title": "System Status",
            "type": "page"
        },
        "hidden": false,
        "message": "",
        "minorEdit": false,
        "number": 2,
        "when": "2024-09-03T11:18:34.133-04:00"
    }
}

Somehow I am receiving less information. I am trying to get to the point where I am able to see the ADF and the table nodes within my page.

If there is a better means to have this discussion not in the community that would also be appreciated so I don’t have to worry about exposing my team’s personal info.

@JackLoCasto,

That endpoint is marked “deprecated” and expected to be removed. I don’t recommend relying upon it.

That said, the expand you want is body.

You can open a developer support ticket for a private ticket, but your needs may not fit the service they offer. I think open questions and learning are best handled here on the dev community. I do understand that does take some extra work to redact request/responses headers & bodies.