I'm trying to append content to an existing confluence wiki page. So far, I can see only PUT exists and it overwrites the whole page.
I also tried to pull the existing content, then append the changes automatically locally and then push again but for some reason, all the emojis/icons replaced with a blue star...
Extract data for edit:
response = requests.get("https://<compnay>.atlassian.net/wiki/rest/api/content/" + page_id + "?type=blogpost&start=0&limit=10&expand=body.view",
auth=(email, apitoken), verify=False)
The PUT code example:
new_headers = {
'Content-Type': 'application/json',
}
data = r'{"id":"' + page_id + '",' \
'"type":"page",' \
'"title":"' + page_title + '",' \
'"space":{"key":"' + workspace + '"},' \
'"body":{"storage":' \
'{"value":"' \
'' + full_code + '<p />",' \
'"representation":"storage"}},"version":{"number":' + str((int(version_number) + 1)) + '}}'
response = requests.put('https://<company>.atlassian.net/wiki/rest/api/content/'+page_id, headers=new_headers,
data=data, auth=(email, apitoken))
Which brings up 2 questions:
More Important: How is it possible to append content to an existing wiki page, without overwriting or deleting the existing content within it?
Less Important: Why the emojis changed to blue star? How can I avoid it?
Hi!
@Gadi Tabak could you fetch in &expand=body.storage instead of
&expand=body.view
?
Then you can do concatenation and push data.
I hope next example will help you
https://github.com/atlassian-api/atlassian-python-api/blob/master/atlassian/confluence.py#L1217
https://github.com/atlassian-api/atlassian-python-api/blob/master/atlassian/confluence.py#L1276
Cheers,
Gonchik
Well, it seems I was checking body.view instead of body.storage the whole time. This is the source to my mistake.
What I eventually did is to fetch the data from body.storage, then manipulated it with re Python library and sent it again to modify the page.
Thank you Gonchik for giving me this lead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're welcome!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Could you please share the piece of code on how you update the confluence page.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.