Confluence Server API 8.5.2 Update Content Problem

Someone November 2, 2023

I am using Python to connect to API. I want to find and replace some texts in pages with new texts while keeping the HTML/CSS formating.

But for Content-Type, the PUT API seems to only support "

application/json", "not "text/html" (415). The result is that all of my tags are interpreted as text and not as html tags when it updates.
So is there a way to do that?

1 answer

0 votes
Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 2, 2023

@jimqian, could you provide an example of what you are trying to insert? 

Someone November 2, 2023

<p>apple apple.</p><p><span style="color: rgb(206,145,120);">New Sentence</span></p><p>banana</p><p><span style="color: rgb(206,145,120);">New Sentence.</span></p><p>orange</p><p><span style="color: rgb(206,145,120);">New Sentence.</span></p><p>pineapple</p>

Someone November 2, 2023

I am basically trying to change "Old Sentence." to "New Sentence." for example. While ignoring things that are neither: like "pineapple" and also keeping the original formatting: like <p>, <span, and color.

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 2, 2023

And it's being inserted directly as that? Are you inserting it inside of an HTML macro?

Also, are you putting in "&lt;p&gt;apple apple.&lt;/p&gt;..." are did it just render that way when you put it into the text box here?

Someone November 2, 2023

No I did not use the HTML macro. What is that? Thank you very much for pointing it out!

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 2, 2023

@jimqian, you need to enable it at the system level. https://confluence.atlassian.com/doc/html-macro-38273085.html

Someone November 2, 2023

So basically:

1) Tell my wiki's admin to enable HTML macro and

2) Add {html} {html} around my html code when using API to put?

Someone November 2, 2023

And btw would using scriptrunner instead of api circumvent this problem without having the admin enable html?

Someone November 2, 2023

Nvm. And thank you Kian Stack Mumo Systems for your help!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events