function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alex ChudovskyAlex Chudovsky 

JSON_PARSER_ERROR with Dashboards REST API

The problem appears when I try to save a dashboard using PATCH method of Dashboards REST API. I do this by the same way as it said in the developer guide (https://developer.salesforce.com/docs/atlas.en-us.api_analytics.meta/api_analytics/analytics_api_dashboard_save_dashboard.htm)
I tried different variants of PATCH request body, but in the response I got the same error:
{"errorCode":"JSON_PARSER_ERROR","message":"The request body is either invalid or incomplete."}

Request sends to https://ap2.salesforce.com/services/data/v36.0/analytics/dashboards/IdOfDasboard

Body of the request is:
{
	"dashboardMetadata": {
		"name": "TestDashboard"    
	}
}

Have anybody any ideas why it happens?

Thank you,
Alexei Chudovsky 
Best Answer chosen by Alex Chudovsky
Mark NordbergMark Nordberg
I found that the documentation is wrong.    You shouldn't pass it the dashboardMetadata : {} but rather just tell it the new name.   See if you can use patch and that syntax to change the name of the dashboard.    It works for me.    Other things don't like changing the layout.
{
        "name": "TestDashboard"   
}

All Answers

Kiran  KurellaKiran Kurella
Per documentation, you need to "Use a PATCH request on the Dashboard Results resource to save changes to a dashboard.". I think you need to retrieve "Dashboard Results" first and apply a patch to the entire result set.

https://developer.salesforce.com/docs/atlas.en-us.api_analytics.meta/api_analytics/analytics_api_dashboard_results_resource.htm#topic-title
Alex ChudovskyAlex Chudovsky
Hi Kiran!
Thank you for your reply.

According to your advice I tried to send request based on previous retrieved results but I got the same error (JSON_PARSER_ERROR).

Here is request body I sent:
"attributes": {
    "dashboardId": "01Z28000000M7PEEA0",
    "dashboardName": "InterestindDashboard",
    "describeUrl": "/services/data/v36.0/analytics/dashboards/01Z28000000M7PEEA0/describe",
    "statusUrl": "/services/data/v36.0/analytics/dashboards/01Z28000000M7PEEA0/status",
    "type": "Dashboard"
},
"componentData": [
    {
        "componentId": "01a28000000MbeoAAC",
        "reportResult": null,
        "status": {
            "dataStatus": "NO_DATA",
            "errorCode": null,
            "errorMessage": null,
            "errorSeverity": null,
            "refreshDate": "2016-05-23T10:01:12.000+0000",
            "refreshStatus": "IDLE"
        }
    }
],
"dashboardMetadata": {
    "canChangeRunningUser": false,
    "components": [
        {
            "componentData": 0,
            "footer": "Footerchik",
            "header": "TestHeaderchik",
            "id": "01a28000000MbeoAAC",
            "properties": {
                "aggregates": [
                    {
                        "name": "RowCount"
                    }
                ],
                "autoSelectColumns": true,
                "groupings": null,
                "maxRows": null,
                "sort": null,
                "useReportChart": false,
                "visualizationProperties": {
                    "breakPoints": [
                        {
                            "aggregateName": "RowCount",
                            "breaks": [
                                {
                                    "color": "c25454",
                                    "lowerBound": 0,
                                    "upperBound": 1
                                },
                                {
                                    "color": "c2c254",
                                    "lowerBound": 1,
                                    "upperBound": 2
                                },
                                {
                                    "color": "54c254",
                                    "lowerBound": 2,
                                    "upperBound": 3
                                }
                            ]
                        }
                    ],
                    "showPercentages": false,
                    "showTotal": true
                },
                "visualizationType": "Gauge"
            },
            "reportId": "00O28000006Tzc5EAC",
            "title": "Ololololo",
            "type": "Report"
        }
    ],
    "description": null,
    "developerName": "InterestindDashboard",
    "filters": [],
    "folderId": "00528000001tqmoAAA",
    "id": "01Z28000000M7PEEA0",
    "layout": {
        "columns": [
            {
                "components": [
                    0
                ]
            }
        ],
        "gridLayout": false
    },
    "name": "InterestindDashboard",
    "runningUser": {
        "displayName": "Alexei Chudovsky",
        "id": "00528000001tqmoAAA"
    }
}

Have you any more ideas or example of correct request body?

Thank you,
Alexey
Mark NordbergMark Nordberg
I found that the documentation is wrong.    You shouldn't pass it the dashboardMetadata : {} but rather just tell it the new name.   See if you can use patch and that syntax to change the name of the dashboard.    It works for me.    Other things don't like changing the layout.
{
        "name": "TestDashboard"   
}
This was selected as the best answer
Alex ChudovskyAlex Chudovsky
Thanks, Mark Nordberg! You are quite right!