How can I update a table in a page via API?

Matt January 24, 2023

I'm having difficulty understanding how I can update a specific table within Confluence without having to update the entire page or is that my only option?

def update_page(id):
  url = "https://company-confluence.atlassian.net/wiki/rest/api/content/{}"
  payload = json.dumps({
    "body": {
      "storage": {
        "value": '<table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th>Circuit Type</th> <th>Provider</th> <th>Bandwidth</th> </tr> </thead> <tbody> <tr> <td>MPLS</td> <td>Verizon1</td> <td>100M</td> </tr> <tr> <td>DIA</td> <td>Spectrum</td> <td>300M</td> </tr> </tbody> </table>',
        "representation": "storage"
      }
    }
  })
  headers = {
    'Authorization': 'Basic basdfklhjasjikdhf34j;l',
    'Content-Type': 'application/json'
  }
  response = requests.request("PUT", url.format(id), headers=headers, data=payload)
data = update_page(id)
if data == 200:
  print("Success")

1 answer

1 accepted

0 votes
Answer accepted
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 25, 2023

Hi @Matt  and welcome!

Unfortunately, table is part of the page content so you need to update the whole page.

Hope this helps,

Fabio

Matt January 27, 2023

You are correct. Turns out however, I can use python format method to update field. Thanks

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events