Hi Team,
I am able to create the blank page in confluence using rest api.
If I try to create a page having JIRA macro I am not getting succeeded .
Below is the snippet for creating a page.
createPage = "{\"type\":\"page\",\"title\":\"new page\",\"space\":{\"key\":\"OMS\"},"
+ "\"body\":{\"storage\":{\"value\":\"\"<h2>Display the Sprint -Sprint 5 which is closed issues.</h2><p />"
+ "\"<ac:structured-macro ac:name=\\\"jira\\\" ac:schema-version=\\\"1\\\" data-layout=\\\"full-width\\\" ac:macro-id=\\\"dads2-6csdff-dsd-r6ff-6dfgdb232\\\">"
+ "\"<ac:parameter ac:name=\\\"server\\\">System JIRA</ac:parameter><ac:parameter ac:name=\\\"maximumIssues\\\">20</ac:parameter>"
+ "\"<ac:parameter ac:name=\\\"columns\\\">key,summary,type,created,assignee,reporter,priority,status,resolution</ac:parameter>"
+ "\"<ac:parameter ac:name=\\\"jqlQuery\\\">Sprint = "OMS Sprint 5" and status=close and project = OMS </ac:parameter>"
+ "\"<ac:parameter ac:name=\\\"serverId\\\">3f701a8d-470a-3309-8926-3b7be06fa653</ac:parameter></ac:structured-macro><p />"
+ "\",\"representation\":\"storage\"}}}";
Please any one can help me on this.
My hunch is there is something off in the raw post. Probably something is not escaped properly. I would first mock it up in Confluence and get the storage format for the page. Then run that storage format through a tool to escape out the string for JSON such as below ...
https://www.freeformatter.com/json-escape.html
https://codebeautify.org/json-escape-unescape
Then craft your JSON using the escaped string. Next, you will need to escape the JSON to work within a string. So take that JSON with the escaped storage format and escape that whole thing out again. Not sure what language you are using but here is one for JavaScript.
https://codebeautify.org/javascript-escape-unescape
Then take that out put and put it back into your project to see if it works.
Hi Davin,
Thanks for your reply,
I am using java code to achieve this. After changing the JSON escape format also no luck.
I got the "500 Internal Server Error".
Can you please help me on this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi! I'm not sure about the snippet part, but you could always try creating a template with the Jira macro, so every time you create a page from that template the jira macro will be added. Hope this helps :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
is there any api's are available for creating a template instead of page in 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.