Extra Inventory for Cockpit - Home

Ok, I think I got it.
Here is my Workflow:

  1. Add the image widget to the dashboard with a dummy image.
  2. Get your dashboard ID and save the c8y_Dashboard fragment for step 5 (Request)
  3. Upload the new image with this python script.
import requests

url = "https://<tenant>/inventory/binaries"
headers = {
  "Authorization": "Basic <Auth>",
  "Accept": "application/json"
}
payload = { 'object' : '{ "name" : "image.jpg", "type" : "image/jpeg", "c8y_Global": {} }'}
files = {"file": ("image.jpg", open("image.jpg", "rb"), "image/jpeg") }

response = requests.request("POST", url, headers= headers, data= payload, files= files)
print(response.text.encode("utf8"))
  1. Add the new image to the dashboard managed object as additional resource (Request)
  2. Update the dashboard managed object with a new c8y_Dashboard fragment where the image ID is changed to the new one. (Request)
  3. Delete the dummy image from your Binaries (Request)
1 Like