Bootstrap FreeKB - Atlassian - Update Confluence Page using Python
Atlassian - Update Confluence Page using Python

Updated:   |  Atlassian articles

This assumes you have already created an API token and have a base 64 encoded string of the API token. Check out my article FreeKB - Atlassian - Create API token.

Using the base64 encoded string, you should now be able to submit a GET request and get JSON response. For example, to GET Confluence Pages.

More GET request examples here => The Confluence Cloud REST API

import json
import requests


payload = json.dumps({
  "id": "<the ID of the page you want to update>",
  "status": "current",
  "title": "<the new title of the page>",
  "body": {
    "representation": "storage",
    "value": "<the new body of the page>"
  },
  "version": {
    "number": 2,
    "message": "updating page version to 2"
  }
})

response = requests.put(
  f"https://acme.atlassian.net/wiki/api/v2/pages",
  headers={ "Accept": "application/json", "Content-Type": "application/json", "Authorization": "Basic <your base64 encoded API token>" },
  data=payload  
)
print(response.json())

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 3d3075 in the box below so that we can be sure you are a human.