Files
Gainsight/Scripts/API_Notes/confluence_post.py

47 lines
1.4 KiB
Python
Raw Normal View History

2022-10-03 18:59:40 -04:00
# This code sample uses the 'requests' library:
# http://docs.python-requests.org
import requests
from requests.auth import HTTPBasicAuth
import json
url = "https://northpass.atlassian.net/wiki/rest/api/content"
#auth = HTTPBasicAuth("bnJhc211c3NlbkBub3J0aHBhc3MuY29tOnFmOUlsN1g0d2t0aGdRS0JPSWx5NTczNw==")
2022-10-11 09:12:11 -04:00
# Find a page CURL
#curl -u admin:admin -X GET "http://localhost:8080/confluence/rest/api/content?title=myPage%20Title&spaceKey=TST&expand=history" | python -mjson.tool
2022-10-03 18:59:40 -04:00
auth = HTTPBasicAuth("nrasmussen@northpass.com", "qf9Il7X4wkthgQKBOIly5737")
headers = {
"X-Atlassian-Token": "no-check",
"Accept": "application/json",
"Content-Type": "application/json"
}
payload = json.dumps( {
"type":"page",
2022-10-10 17:28:58 -04:00
"title":"Customer Name",
2022-10-03 18:59:40 -04:00
"ancestors":[{"id":2210463745}],
"space":
{"key":"~350535240"},
"body":
{"storage":
{"value":
2022-10-10 17:28:58 -04:00
"<p>A Customer Page</p> <ac:structured-macro ac:name='expand' ac:schema-version='1'><ac:rich-text-body><p>Customer Content * Item1 * Item 2 1. Item3 2. Item 4</p></ac:rich-text-body></ac:structured-macro>",
2022-10-03 18:59:40 -04:00
"representation":"storage"}}
} )
response = requests.request(
"POST",
url,
data=payload,
headers=headers,
auth=auth
)
2022-10-10 17:28:58 -04:00
response = json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": "))
print(response)
2022-10-11 09:12:11 -04:00
#x = response.split()
#print(x)
2022-10-10 17:28:58 -04:00