Can't get dashboard gadget's filtername or filterid with rest api

I have a Bubble Chart gadget in a dashboard, I am using the following rest api call to get the filtername or filterid, but failed:

url = f"{base_url}/rest/api/3/dashboard/{self.dashboard_id}/items/{gadget_id}/properties/config"
r.status_code: 404
r.text: {"errors":{},"errorMessages":["The property config does not exist."],"httpStatusCode":{"empty":false,"present":true}}

I have another gadget which has multiple filters like ‘Last 2 day to 7 day inreview bug’, I can’t get the filter either,

Can anyone help me?
Thanks
Jayden

Hello @JaydenZhang and welcome to the Developer Community

I just did a test lookup up the property keys of a bubble chart gadget on a dashboard, and there is no such property key as config, so the error message seems to be completely correct.

I suggest that you do a lookup of all the property keys of that gadget (dashboard item) via the Get dashboard item property keys endpoint first to know what property keys are available to query.

I think you’ll find that the property key called id contains the id of the project or filter the gadget is using, and the property key called name contains the name of the project or filter the gadget is using.

@sunnyape ,
Thanks for your reply.
I tried the following endpoint:

url = f'{base_url}/rest/api/3/dashboard/{self.dashboard_id}/items/{gadget_id}/properties'
r.status_code: 200
r.json(): {
    "keys": [
        {
            "key": "itemkey",
            "self": "https://accaella.atlassian.net/rest/api/3/dashboard/<dashboard_id>/items/<gadget_id>/properties/itemkey"
        }
    ]
}

Yes, because this time you didn’t provide ANY property key with the request. You must provide at least one, valid value for the propertyKey request parameter, as per the documentation for that endpoint:

GET /rest/api/3/dashboard/{dashboardId}/items/{itemId}/properties/{propertyKey}

So you need either:

url = f’{base_url}/rest/api/3/dashboard/{self.dashboard_id}/items/{gadget_id}/properties/id’

or

url = f’{base_url}/rest/api/3/dashboard/{self.dashboard_id}/items/{gadget_id}/properties/name’

@sunnyape,
Thanks,
I can get the id and name sucessfully:

f’{base_url}/rest/api/3/dashboard/{self.dashboard_id}/items/{gadget_id}/properties/id’, 
r.status_code: 200
r.json(): {
    "key": "id",
    "value": 13990
}

’{base_url}/rest/api/3/dashboard/{self.dashboard_id}/items/{gadget_id}/properties/name’
r.json(): {
    "key": "name",
    "value": "xxxxxxxxxxxxxxxxx"
}

I tried to update the value with requests.put, but failed, so how can I update the id or name with new value?

Then please mark my original answers as correct.

I tried to update the value with requests.put but failed.

You are now changing topics to a different subject to your original question, but I’ll answer it this time.

It’s not clear if you’re trying to change the configuration of the gadget by remotely altering the filter or project it is using, or if you’re trying to somehow change the ‘name’ that the gadget shows for that filter or project.

You also seem to be confusing functionality provided by the UI with the functionality provided by the REST API.

First, you’re not taking the time to read the documentation properly. The Set dashboard item property endpoint documentation says that you just provide the value in the request body, nothing else, so it would be:

r.json(): "Random new name here"

Next, if you do use the REST API to change the name property, then look at the bubble chart in the UI, you’ll see its functionality didn’t change. If you then edit the gadget and look at its configuration, you’ll see the name is what you set it as!!. This is because, behind the scenes, it is the id of the filter or project is what is really is being used to display content, and the name of that filter or project is provided in the UI as a subsequent by-product, for aesthetic reasons, since nobody using the UI would know what ‘102345’ means.

In summary, you can’t change the name property and expect the gadget’s functionality to change, only what is shown in the UI. You should set the id property, using a valid project or filter id, if you want to change the functionality.

Here’s a good experiment. Use the Set dashboard item property endpoint to set a property called hiddenProperty to the value “I’m not visible”, then use the Get dashboard item property keys endpoint to lookup all the property keys and their values. The new property and its value will be there. Then go to the UI, inspect the configuration of the gadget and see if you can find it anywhere.

Try doing some experiments with your API test tool to try different combinations for these sorts of requests and their values, then observing the resulting effect on the gadget in the UI first, rather than jumping to conclusions and immediately asking for help.

Have fun. Bye.