Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using JIRA REST API how to update gadgets

Vishal Biyani
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.
February 15, 2024

i have been able to add a gadget in the dashboard using REST APIs

url = "https://your-domain.atlassian.net/rest/api/3/dashboard"

and

url = "https://your-domain.atlassian.net/rest/api/3/dashboard/{dashboardId}/gadget"

 

Once a gadget is added, which REST API to use to populate the gadget?

e.g. i added Filter Count gadget. Now how do i add using REST API

1. filter

2. specify the counts

1 answer

1 accepted

0 votes
Answer accepted
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
February 15, 2024

Hi @Vishal Biyani , I think you will need to use following rest endpoint:

Vishal Biyani
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.
February 15, 2024

@Martin Bayer _MoroSystems_ s_r_o__ 


i added the dashboard gadget using

url = "https://your-domain.atlassian.net/rest/api/3/dashboard/{dashboardId}/gadget"

got the itemId using = 

response.json()["id"]

Now when i try to run below API, replacing dashboardId and itemId received from above

url = "https://your-domain.atlassian.net/rest/api/3/dashboard/{dashboardId}/items/{itemId}/properties"

 

getting 404

b'{"message":"null for uri: https://your-domain.atlassian.net/rest/api/3/10671/items/39921/properties","status-code":404}'

Not sure why is that happening. i even added a sleep of 5 seconds to ensure the gadget is getting added to the dashboard

Vishal Biyani
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.
February 15, 2024

@Martin Bayer _MoroSystems_ s_r_o__ 

never mind. i had missed dashboard and hence was getting 404 :-(

The issue is resolved now. thanks for your guidance though

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
February 16, 2024

Hi @Vishal Biyani , sorry for the late reply, but I'm happy that you were able to resolve the problem yourself :)

You can accept the answer if you think it could help other users...

Vishal Biyani
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.
February 16, 2024

@Martin Bayer _MoroSystems_ s_r_o__ 

I am able to add "Filter Results" gadget using put method.

However, I am struggling to add "Filter Counts" gadget. i am not sure what is the  right payload to use. 

I tried using two calls with below payload

for projectFilterDetails i used 

payload_value={"id": "11860", "type": "filter",}

for countOptions i used

{
"hasTrigger": False,
"trigger":
{
"display": "warning",
"triggerEquality": "above",
"triggerOn": "undefined"
},
"name": "High+ Open",
"jql": "priority in (Critical, High, 'Show Stopper') and status in (Open, 'In Progress')",
"id": "c976"
}

When i call put API i get 201 and i can browse the end point

But on dashboard, the gadget shows error and does not allow me to edit it also.

 

Any guidance with this will be helpful.

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
February 16, 2024

Hi @Vishal Biyani following PUT works fine for me:

  • https://{domainname}.atlassian.net/rest/api/3/dashboard/{dashboardid}/items/{filterCountGadgetid}/properties/projectFilterDetails
  • JSON: 
    • {"name":"some name displayed on the top of the gadget","type":"filter","id":"10002"}
Vishal Biyani
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.
February 19, 2024

@Martin Bayer _MoroSystems_ s_r_o__ 

Thanks. Based on your response, i debugged further and after fixing the issue related to payload, this works fine.

Is there any place where it is documented what are the various propertyKey available for a gadget? 

 

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
February 22, 2024

Hi @Vishal Biyani , good job :).

Unfortunatelly these keys are not documented because every gadget (even your custom implementation) can contain different properties. That's why there is REST API which will return the properties and you just need to understand how to use the API :).

If my answer was helpful, feel free to accept the answer.

Vishal Biyani
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.
February 22, 2024

@Martin Bayer _MoroSystems_ s_r_o__ 

Your guidance was very useful in getting creation of dashboard automated.

Accepted the answer.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events