Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Create a confluence page having the JIRA macro or JIRA filter.

naveenkumar_dp December 12, 2019

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 =  &quot;OMS Sprint 5&quot;  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.

2 answers

0 votes
Davin Studer
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 12, 2019

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.

naveenkumar_dp December 12, 2019

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.

0 votes
Andrea Mendez
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 12, 2019

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 :)

naveenkumar_dp December 12, 2019

Hi,

is there any api's are available for creating a template instead of page in confluence?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events