0

I need to create a confluence page via REST API which contains a JIRA Chart

according to: https://confluence.atlassian.com/display/DOC/JIRA+Chart+Macro and https://developer.atlassian.com/display/CONFDEV/Confluence+REST+API+Examples

my implement code is

curl -u myusername:mypassword -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"A_Test_page","space":{"id":123456789,"key": "~myusername"},"body":{"storage":{"value":"
<ac:structured-macro ac:name="jirachart">
  <ac:parameter ac:name="chartType">pie</ac:parameter>
  <ac:parameter ac:name="statType">assignee</ac:parameter>
  <ac:parameter ac:name="showinfor">true</ac:parameter>
  <ac:parameter ac:name="jql">Some JQL</ac:parameter>
  <ac:parameter ac:name="border">false</ac:parameter>
  <ac:parameter ac:name="server">My Jira Server Name</ac:parameter>
  <ac:parameter ac:name="serverId">144880e9-a353-312f-9412-e5028e8166fa</ac:parameter>  <!-- I don't have this information -->
</ac:structured-macro>
","representation":"storage"}}}' http://my.wiki.server/rest/api/content | python -mjson.tool

The question is: If I don't know "serverId", is there any alternative (eg: direct to JIRA url with authentication info...) or work-arround to get the JIRA Chart up on the page?

Thank you in advance.

yelliver
  • 5,648
  • 5
  • 34
  • 65

2 Answers2

0

I don't think it's possible. What you could possibly do is query the REST api to get the serverId:

curl -u myusername:mypassword -X GET -H 'Accept: application/json' http://my.wiki.server/rest/applinks/1.0/listApplicationlinks | python -mjson.tool
mattr
  • 1
  • Thanks, mattr. I've tried your solution but got { "message": "Only an admin can access this resource.", "status-code": 401 } – yelliver Sep 15 '14 at 09:09
  • 1
    Finally, I've got ServerId and it works, but I asked this question because I could get Jira Issues without a ServerId as bellow: type,key,summary,assignee my.jira.server fasle – yelliver Sep 15 '14 at 09:19
  • Oh, I assumed that you were an admin, sorry. – mattr Sep 15 '14 at 15:12
0

there is also another (albeit not very elegant yet effective) way: just look in the source by querying the confluence rest api. Simply create whatever you want to accomplish in confluence first and then do a query to let confluence tell you the source:

curl -s -u user:pass -X GET "http://your.confluence.com/confluence/rest/api/content?title=testpage&spaceKey=SPACEKEY&expand=body.storage"
knrr
  • 21
  • 3