You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
We are getting the dashbords list in json with "api/2/dashboard/{dashboardId}".
In one of the dash board it has lot of graphs there. Now, is there any way we can try to pull the values of each graph ?
Next, what is 'items' and itemid in the dashboard URL . How can we identify values ? How to obtain {ItemId} in api/2/dashboard/{dashboardId}/items/{itemId}/properties.
There is no possibility to find out the itemid from API. Only way I find the itemid is from source code of page.
<div class="dashboard-item-frame gadget-container" id="gadget-17972-chrome">
"17972" is the itemid.
I'm not sure when this ID is changed and if it'll stay the same all the time... but at least there is some way how to find it out.
Recently I found some weird pattern in dashboard html... The gadget ID always show twice in the original html. So I wrote these codes to fetch gadget ID from a dashboard. Hope this will help you :)
def initLink(method,url,auth,headers,payload):
response = requests.request(
method,
url,
headers=headers,
auth=auth,
data=payload
)
return response
def getHtml(dashboardId):
url = "https://your-domain.atlassian.net/jira/dashboards/"+dashboardId
headers = {
"Accept":"application/json"
}
response = initLink("GET",url,auth,headers,"")
return response.text
def generateGadgetList(dashboardId):
html = getHtml(dashboardId)
gadgetPat = re.compile("\"id\":\"(\d{5})\"")
gadgetList = gadgetPat.findall(html)
count = {}
result = []
for gadget in gadgetList:
if gadget in count.keys():
count[gadget]+=1
else:
count[gadget]=1
for key,value in count.items():
if value==2:
result.append(key)
return result
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the script.
I had to make a few changes to it for our API access but otherwise it worked perfectly. My slightly modified script:
import requests
import re
def initLink(method,url,auth,headers,payload):
response = requests.request(
method,
url,
headers=headers,
auth=auth,
data=payload
)
return response
def getHtml(dashboardId):
url = "https://kargo1.atlassian.net/jira/dashboards/"+dashboardId
myHeader = {'Authorization': 'Basic a3RjQGthcmdvLmNvbTpldVFvbXhwd3RtaGpBUUh1UW10VDVBNjQ=', 'Content-Type': 'application/json'}
results = requests.get(url, headers=myHeader)
return results.text
def generateGadgetList(dashboardId):
html = getHtml(dashboardId)
gadgetPat = re.compile("\"id\":\"(\d{5})\"")
gadgetList = gadgetPat.findall(html)
count = {}
result = []
for gadget in gadgetList:
if gadget in count.keys():
count[gadget]+=1
else:
count[gadget]=1
for key,value in count.items():
if value==2:
result.append(key)
return result
#+++++++++++++++++++++++++++++++++++++++++
# PROGRAM STARTS HERE
#+++++++++++++++++++++++++++++++++++++++++
arrGadets = generateGadgetList("14726")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I know this post is super old, but....I believe I found a way to get the dashboard/gadget id's using ScriptRunner.
This script comes from their how to automatically create a Dashboard...
Go to your SR console and add the following script...only thing you'll need to update is the Dashboard ID you want to get the info from
import com.atlassian.jira.bc.JiraServiceContext
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.bc.portal.PortalPageService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.portal.PortletConfiguration
import groovy.json.JsonOutput
import groovy.xml.MarkupBuilder
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
JiraServiceContext sourceUserServiceCtx = new JiraServiceContextImpl(user)
def portalPageService = ComponentAccessor.getComponent(PortalPageService)
//your dashID is equal to your PageID url - the number it provides
def dashId = 19300
def output = portalPageService.getPortletConfigurations(sourceUserServiceCtx, dashId).collect { col ->
col.collect { PortletConfiguration gadget ->
[
//by chance...added this...and it works!
id : gadget.id,
//the script below is directly from SR how to's
row : gadget.row,
column : gadget.row,
color : gadget.color,
openSocialSpecUri: gadget.openSocialSpecUri.getOrNull().toString(),
completeModuleKey: gadget.completeModuleKey.getOrNull().toString(),
userPrefs : gadget.userPrefs,
]
}
}
def prettyOutput = JsonOutput.prettyPrint(JsonOutput.toJson(output))
log.debug(prettyOutput)
def writer = new StringWriter()
def builder = new MarkupBuilder(writer)
builder.pre(prettyOutput)
writer
When you run the code above, you get:
[
[
{
"id": 24200,
"row": 0,
"column": 0,
"color": "color1",
"openSocialSpecUri": "rest/gadgets/1.0/g/com.atlassian.jira.gadgets:text-gadget/gadgets/text-gadget.xml",
"completeModuleKey": "null",
"userPrefs": {
"isConfigured": "true",
"refresh": "false",
"html": "var gadget = AJS.Gadget({\r\n...\r\n\tview: {\r\n\t\t...\r\n \ttemplate: function (args) {\r\n\t\t\t...\r\n\t\t\tvar gadgetId = this.getPrefs().getModuleId();\r\n\t\t\t...\r\n\t\t}\r\n\t}\r\n...\r\n});",
"title": ""
}
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lara, thanks for your answer! Do you know if this would be possible to do without the use of script runner?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Joshua Cheung - If you can chat with a System Admin who knows their way around Jira...maybe from the backend? Not 100% sure, but I don't believe that it's possible any other way from the front end.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From the docs-
A dashboard item is similar to a gadget, in that it provides discrete dynamic content that a user can use to customize their dashboard. However, dashboard items use modern rendering technologies like AMD, Soy, LESS, etc. Dashboard items are also able to share web-resources, which greatly improves page load performance by reducing the number of requests and the overall size of data to be transferred on a dashboard load.
Currently, it doesn't seem possible to fetch list of items of dashboard using REST API, similar question here -
https://answers.atlassian.com/questions/39553910
In the latest API documentation - https://docs.atlassian.com/jira/REST/server/#api/2/dashboard-list
There is no method getting dashboard item list, something like - GET /rest/api/2/dashboard/{dashboardId}/items/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tarun,
what data we need to pass in 'itemid' in URL which is under 'dashboard/items'.
Say for example : one of the dash board has a single Pie Gadget.
Now, what I need to pass a value for an itemid in 'api/2/dashboard/{dashboardId}/items/{itemId}/properties' URL ?
Please provide an answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I will suggest you to create your own REST end point using the script runner plugin or the REST plugin module and use the Java API of the script runner to fetch the details of the dashboard gadgets.
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.