Getting Message Not Found Error While Creating a Dashboard

Hi,

I am trying to create a dashboard in a folder in grafana with api.
There is a folder already yet there is no dashboard inside it.

I am sending a request to the this url → /api/dashboards/db with the proper api key and other headers but getting an error like this and this doesn’t make sense for me and I couldn’t find a way to solve it.

{
    "message": "Not found"
}

This is my request body:

{
    "dashboard": {
        "id": null,
        "uid": null,
        "title": "Service Level Objectives - XX",
        "tags": [
            "test",
            "test2"
        ],
        "timezone": "browser",
        "panels": [
            {
                "title": "Test (Error Rate)",
                "description": null,
                "datasource": "Prometheus",
                "cacheTimeout": null,
                "colorBackground": false,
                "colorValue": true,
                "colors": [
                    "#299c46",
                    "#e0752d",
                    "#bf1b00"
                ],
                "decimals": 3,
                "format": "percentunit",
                "gauge": {
                    "maxValue": 100,
                    "minValue": 0,
                    "show": false,
                    "thresholdLabels": false,
                    "thresholdMarkers": false
                },
                "gridPos": {
                    "h": 4,
                    "w": 6,
                    "x": 0,
                    "y": 0
                },
                "interval": null,
                "links": [],
                "mappingType": 1,
                "mappingTypes": [
                    {
                        "name": "value to text",
                        "value": 1
                    },
                    {
                        "name": "range to text",
                        "value": 2
                    }
                ],
                "maxDataPoints": 100,
                "nullPointMode": "connected",
                "nullText": null,
                "postfix": "",
                "postfixFontSize": "50%",
                "prefix": "",
                "prefixFontSize": "70%",
                "rangeMaps": [
                    {
                        "from": "null",
                        "text": "N/A",
                        "to": "null"
                    }
                ],
                "sparkline": {
                    "fillColor": "#447ebc",
                    "full": false,
                    "lineColor": "#e0f9d7",
                    "show": true
                },
                "tableColumn": "",
                "targets": [
                    {
                        "expr": "sum(slo_Test_FailureCount) / sum(slo_Test_SuccessCount + slo_Test_FailureCount)",
                        "datasource": "Prometheus",
                        "intervalFactor": 1,
                        "legendFormat": "Test",
                        "format": "time_series",
                        "hide": false,
                        "refId": "A"
                    }
                ],
                "thresholds": "0.01, 0.1",
                "timeFrom": null,
                "timeShift": null,
                "transparent": true,
                "type": "singlestat",
                "valueFontSize": "100%",
                "valueMaps": [
                    {
                        "op": "=",
                        "text": "N/A",
                        "value": "null"
                    }
                ],
                "valueName": "avg"
            }
        ],
        "templating": {
            "list": []
        }
    },
    "folderId": 83,
    "overwrite": true
}

Do you have any suggestions?

Welcome @guzelcihad

What programming language are you using to do this? Please share code minus sensitive stuff

Python client. Can you also tell me why do you want to see the code? I use postman to send request and shared the json data in the previous mail too

The code something like this:

        data = {
            "dashboard": {
                "id": None,
                "uid": None,
                "title": title,
                "tags": tags,
                "timezone": "browser",
                "panels": panels,
                "annotations": {"list": annotations},
                "templating": {"list": variables},
            },
            "folderId": folderId,
            "overwrite": True,
        }
        resp = self._req("POST", "/dashboards/db", data)
    def _req(self, method, url, req=None):
        headers = {
            "content-type": "application/json",
                "Authorization": "Bearer %s" % self.api_key,
            "X-Disable-Provenance": "true",
        }

        url = self.base_url + url
        data = json.dumps(req, ensure_ascii=False).encode("utf-8") if req else None
        requests.post(
                    url, headers=headers, data=data, verify=False, timeout=5
                )

because my telepathic level is down today. And the force is not strong with me young jedi. :laughing:

A lot of times, the issue ends up being the code has bug(s) an example here

The problem has been solved. The issue was connecting to grafana api via http protocol after changing it to https the problem solved

1 Like