Post Status Macro via Rest API html

Sam Miller December 3, 2024

I successfully post html code on a Confluence page. Everything is working beside the fact that the status macro of confluence is displayed in a strange table format instead of the real status macro. The rest of the html code is displayed in the correct way

 

My html-statement ist:

 

'<ac:structured-macro ac:name=\"status\" ac:schema-version=\"1\" ac:macro-id=\"4db604h0-543b-23ba-sg96-95829c2394d5\"><ac:parameter ac:name=\"colour\">Green</ac:parameter><ac:parameter ac:name=\"title\">test</ac:parameter></ac:structured-macro>'

 

Anyone knows what it could be?

2 answers

0 votes
Sam Miller December 9, 2024

Thank you for you answer. Actually that what you describe is what I think I do.
Therefor my confluence-table-object for example is working just fine.
It is posted in the right way.

Can you post an example how to update a Confluence-Page with the status macro via Rest-API?

Humashankar VJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 9, 2024

Hi @Sam Miller 

Try to set the representation to "storage" as given below and update space key accordingly

{
"type": "page",
"title": "My Page Title",
"space": {
"key": "MYSPACEKEY"
},
"body": {
"storage": {
"value": "<ac:structured-macro ac:name=\"status\" ac:schema-version=\"1\"><ac:parameter ac:name=\"colour\">Green</ac:parameter><ac:parameter ac:name=\"title\">Test</ac:parameter></ac:structured-macro>",
"representation": "storage"
}
}
}

-----------------------------------------------------

Create page JSON - POST /rest/api/content and update page - PUT /rest/api/content/{contentId}

Best Regards

 

0 votes
Humashankar VJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 6, 2024

Hi @Sam Miller 

Avoid using plain HTML. Confluence has trouble interpreting tags when they're treated as literal HTML. Instead, ensure the REST API sends these tags as part of the storage format, without wrapping them in <html> or <body> tags.

Try the correct REST API format. Structure your macro in JSON, posting it in the storage format.

Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events