How to update filters gadget in the new dashboard after copy an existing dashboard

Hi All

I am using REST API to access JIRA server in python script. I am trying to write a script to use copy dashboard functionality to create a new dashboard. Besides, the script will change the filters in the gadget to new filters.

REST API provides limited functions in the dashboard. It can’t create new dashboard and doesn’t provide the gadgets in the dashboard. Is there any good way to write a program/script to achieve the requirements?

Thanks,

John

Hello,

If you want to interact with dashboards within a JAVA Add-on in Jira, Here is the link to the JAVA API related to Dashboards (in the API a dashboard page is called PortalPage)

https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/portal/PortalPage.html

This class represents a Dashboard page in JIRA. It includes dashboard meta data (name, description) as well as information about favouriting and share permissions.

And here you can find the service to manage the dashboards

https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/bc/portal/PortalPageService.html

Hope this help you,

Regards

Hi Jonathan

Thank for your reply. Based on the the information your provided, I need to use PortalPage to get the dashboard. I found the following code to get Portalpage

User user = (User)ComponentAccessor.getCrowdService().getUser(“admin”);
PortalPage portalpage = ComponentAccessor.getComponent(PortalPageService.class).getPortalPage(new JiraServiceContextImpl(user), (long)10201);

I am still have problem in it. 1. Do you use rest api to establish the jira session? 2. how to use the jira session in sample code to get the dashboard?

Thanks,

John

I don’t instance the components this way. I use OSGI in my plugin to resolve the dependency injection automatically. Also I don’t use the REST API inside a plugin , only the JAVA API.

Regarding

You should use the component UserManager (Atlassian JIRA 7.6.1 API) to retrieve an ApplicationUser , that you can use to create the JiraServiceContextImpl