Snapshot API get nothing but {"message":"Not found"}

Try various things to generate a snapshot via the api but can only get as far as {“message”:“Not found”}.

Does this look right ?

curl -H “Authorization: Bearer eyJrIjoiZ0FGRjZTMVVBazFZT0xkdWZzWWlwbXF1MWgyeXlrdW8iLCJuIjoiU25hcHNob3QgQWRtaW4iLCJpZCI6MX0=” -H “Content-Type: application/json” -D @body.json https://xxx.xxx.xxx:3000/api/snapshots

the body.json file is the dashboard json per the API docs.

Getting closer, I had to specify -X POST. Now getting [{“fieldNames”:[“Dashboard”],“classification”:“RequiredError”,“message”:“Required”}] Not sure how to add what it wants…

Here is the json file:

{
“dashboard”:
{
“__inputs”: [
{
“name”: “DS_WHD_TICKETS”,
“label”: “WHD Tickets”,
“description”: “”,
“type”: “datasource”,
“pluginId”: “mysql”,
“pluginName”: “MySQL”
}
],
“__requires”: [
{
“type”: “grafana”,
“id”: “grafana”,
“name”: “Grafana”,
“version”: “5.3.1”
},
{
“type”: “panel”,
“id”: “graph”,
“name”: “Graph”,
“version”: “5.0.0”
},
{
“type”: “datasource”,
“id”: “mysql”,
“name”: “MySQL”,
“version”: “5.0.0”
}
],
“annotations”: {
“list”: [
{
“builtIn”: 1,
“datasource”: “-- Grafana --”,
“enable”: true,
“hide”: true,
“iconColor”: “rgba(0, 211, 255, 1)”,
“name”: “Annotations & Alerts”,
“type”: “dashboard”
}
]
},
“editable”: true,
“gnetId”: null,
“graphTooltip”: 0,
“id”: null,
“links”: [],
“panels”: [
{
“aliasColors”: {
“High”: “#c15c17”,
“Low”: “#64b0c8”,
“Medium”: “#508642”,
“Urgent”: “#bf1b00
},
“bars”: true,
“dashLength”: 10,
“dashes”: false,
“datasource”: “${DS_WHD_TICKETS}”,
“fill”: 1,
“gridPos”: {
“h”: 8,
“w”: 10,
“x”: 0,
“y”: 0
},
“hideTimeOverride”: true,
“id”: 2,
“legend”: {
“alignAsTable”: false,
“avg”: false,
“current”: true,
“max”: false,
“min”: false,
“rightSide”: false,
“show”: false,
“sideWidth”: 150,
“total”: false,
“values”: true
},
“lines”: false,
“linewidth”: 1,
“links”: [],
“nullPointMode”: “connected”,
“percentage”: false,
“pointradius”: 5,
“points”: false,
“renderer”: “flot”,
“seriesOverrides”: [],
“spaceLength”: 10,
“stack”: false,
“steppedLine”: false,
“targets”: [
{
“alias”: “”,
“format”: “time_series”,
“rawSql”: "SELECT UNIX_TIMESTAMP() as time_sec, COUNT(*) as value, CASE L.LOCATION_NAME WHEN ‘High School’ then ‘HS’ WHEN ‘Middle School’ then ‘MS’ WHEN ‘Admin. Office’ then ‘AO’ WHEN ‘Jensen’ then ‘J’ WHEN ‘Karen Acres’ then ‘KA’ WHEN ‘Olmsted’ then ‘O’ WHEN ‘Rolling Green’ then ‘RG’ WHEN ‘Valerius’ then ‘V’ WHEN ‘Webster’ then ‘W’ WHEN ‘Metro West’ then ‘MW’ ELSE L.LOCATION_NAME END as metric FROM JOB_TICKET J, LOCATION L WHERE J.DELETED !=1 AND J.STATUS_TYPE_ID IN (1,2) AND J.LOCATION_ID= L.LOCATION_ID group by J.LOCATION_ID order by field(J.LOCATION_ID,13,4,2,3,5,6,7,8,9,10,12,1,11,14,15,16,17,18,19) ",
“refId”: “A”
}
],
“thresholds”: [],
“timeFrom”: “5m”,
“timeShift”: “1m”,
“title”: “Open Work Orders by Building”,
“tooltip”: {
“shared”: false,
“sort”: 0,
“value_type”: “individual”
},
“transparent”: true,
“type”: “graph”,
“xaxis”: {
“buckets”: null,
“mode”: “series”,
“name”: null,
“show”: true,
“values”: [
“total”
]
},
“yaxes”: [
{
“format”: “short”,
“label”: “Number”,
“logBase”: 1,
“max”: null,
“min”: null,
“show”: true
},
{
“format”: “short”,
“label”: “Priority”,
“logBase”: 1,
“max”: null,
“min”: null,
“show”: false
}
],
“yaxis”: {
“align”: false,
“alignLevel”: null
}
}
],
“schemaVersion”: 16,
“style”: “dark”,
“tags”: [],
“templating”: {
“list”: []
},
“time”: {
“from”: “now-6h”,
“to”: “now”
},
“timepicker”: {
“refresh_intervals”: [
“5s”,
“10s”,
“30s”,
“1m”,
“5m”,
“15m”,
“30m”,
“1h”,
“2h”,
“1d”
],
“time_options”: [
“5m”,
“15m”,
“1h”,
“6h”,
“12h”,
“24h”,
“2d”,
“7d”,
“30d”
]
},
“timezone”: “”,
“title”: “Work Orders Snapshot”,
“uid”: “L13f1FLmk”,
“version”: 1
},
“name”: “Work Orders Snapshot”,
“expires”: 0,
“external”: false
}

===============================================

UPDATE

===============================================

Ok I found the easiest and best way to do what I need. I am now just using phantomjs and getting a jpg of the current live dashboard.

phantomjs --debug=true --web-security=no --ssl-protocol=any --ignore-ssl-errors=yes works.js

works.js contains:

var page = require(‘webpage’).create();

//size of the page
page.viewportSize = {width: 1024, height: 768};

//if you only want a certain area
page.clipRect = {“width”:400,“height”:465,“top”:50,“left”:60};

//authentication stuff
page.customHeaders={‘Authorization’: 'Basic '+btoa(‘USERNAME:PASSWORD’)};

//enter your url to your dashboard
page.open(‘https://XXX.XXX.XXX:3000/d/L13f1FLmk/XXXXXX?orgId=1’, function (status) {
if (status !== ‘success’) {
console.log(‘Unable to load the address!’);
phantom.exit(1);
}

page.evaluate(function() {
                /* This will set the page background color */
        if (document && document.body) {
            document.body.bgColor = '#FFFFFF';
        }
    
        });

setTimeout(function() {
       //enter the path to create the jpg and the name of the file you want
        page.render('/root/snapshot.jpg');
        phantom.exit();
}, 5000);

});

Enjoy :slight_smile: