Hi @JanTeisinger
I recall attempting a similar task, you might only be able to create a new Dashboard object using the Dashboard module.
Maybe some of the workflow I have done previously might help figure some things out. I have a dashboard template and I export this as JSON and save to a .json file, in below script.
from arcgis.gis import GIS
import json
gis = GIS("home")
dsh_item = gis.content.get("***dsh_item_id***")
dsh_tem_data = dsh_item.get_data()
print(json.dumps(dsh_tem_data, indent=4, sort_keys=True))
You can manipulate this JSON in a notepad and then re-associate it to a copied version of the dashboard through an update.
from arcgis.gis import GIS
import json
## open the dashboard template json
## I'd have manipulated this to point to different datasets etc
with open(r"C:\path\to\file.json") as json_data:
data = json.load(json_data)
# connect to AGOL
gis = GIS("home")
## the standard Dashboard template that the JSON was taken from
dsh_item = gis.content.get("***dsh_item_id***")
## copy and save the dashboard
new_dsh = dsh_item.copy(title="New_Title", tags="tag1,tag2,tag3", snippet='Enter summary', description='Enter desc')
dsh_data = new_dsh.get_data()
## apply new JSON to update the copied dashboard
item_properties = {"text":data}
new_dsh.update(item_properties=item_properties)
You will need to become familiar with how the JSON is formatted for a Dashboard, you can do this by creating different Dashboards an exporting the JSON to see how it all works. I haven't done much work with them myself but hopefully some of the stuff above is helpful.
~ learn.finaldraftmapping.com