I want to create a Macro and upload it to specific page (already created) without deleting the existing content, USING Rest API. { Contains macro name and body }
I want to know what API endpoint I should hit and what will be my payload !
With some guidance from WeWeave support, I was able to get this to work with curl and the WeWeave Mermaid Plugin.
Example Mermaid diagram source:
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
Example curl:
% curl --request PUT \
--url "https://$CONFLUENCE_HOSTNAME/wiki/rest/api/content/$CONFLUENCE_PAGEID" \
--user "$CONFLUENCE_USERNAME:$CONFLUENCE_API_TOKEN" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data @- <<'EOF'
{
"version": {
"number": 2
},
"title": "Mermaid Test",
"type": "page",
"body": {
"storage": {
"value": "<p>This is a test Mermaid diagram generated via api call.</p><ac:structured-macro ac:name=\"confluence-mermaid-macro\" ac:schema-version=\"1\" data-layout=\"default\" ac:local-id=\"00eae132-afb8-4cd7-94c9-3572398c2531\" ac:macro-id=\"7c6bf8b2-c833-46ae-80f8-3c504a6708c6\"><ac:parameter ac:name=\"searchText\">graph TD</ac:parameter><ac:parameter ac:name=\"download\">true</ac:parameter><ac:parameter ac:name=\"fullscreen\">true</ac:parameter><ac:parameter ac:name=\"panZoom\">true</ac:parameter><ac:parameter ac:name=\"zoom\" /><ac:parameter ac:name=\"theme\">default</ac:parameter><ac:parameter ac:name=\"disableUseMaxWidth\" /><ac:parameter ac:name=\"copy\">true</ac:parameter><ac:parameter ac:name=\"exportWidth\" /><ac:parameter ac:name=\"height\" /><ac:plain-text-body><![CDATA[graph TD;A-->B;A-->C;B-->D;C-->D;]]></ac:plain-text-body></ac:structured-macro",
"representation": "storage"
}
}
}
EOF
Hi @admin
You have to create your own app for this. Take a look at this article https://community.atlassian.com/t5/Confluence-Cloud-articles/How-to-create-simple-custom-macros-in-Confluence-Cloud/ba-p/1227422
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Alex,
Thanks for the reply.
I guess I was not able to put my question well.
Can you please explain the format of API and the Payload I need to use for respective API?
Thanks !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @admin
Take a look at this http request https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-custom-content/#api-custom-content-id-put
You will find all the details about the payload in many formats like cURL, node.js, java, python and php.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@admin Were you able to add the mermaid diagram using REST API ?
@Alex Koxaras -Relational- : How can we identify what is the custom content type or Id for mermaid diagram confluence?
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.