How to change text in panel using python script?

Friends, please tell me: how to write a request for updating the text in the panel?
I’ve tried different ways, but it doesn’t work. My code is below:

import requests

grafana_url = ''  
api_key = 'eyJrIjoiajBZNDZ'  
dashboard_uid = 'lFu1yKN7z' 
panel_id = 34  

new_text = """

headers = {
    'Authorization': f'Bearer {api_key}',
    'Content-Type': 'application/json'

dashboard_response = requests.get(f'{grafana_url}/api/dashboards/uid/{dashboard_uid}', headers=headers)
dashboard_data = dashboard_response.json()

for panel in dashboard_data['dashboard']['panels']:
    if panel['id'] == panel_id:
        panel['options']['content'] = new_text

Do any of the data point such as above return any data?


Yes, when displaying the value from here, I get the text that is currently present in my panel. I would like to use a python script to change it

1 Like

So you are currently changing an in memory variable. The data needs to be saved.

Which documentation did you use for this approach?

Better yet check this update api endpoint