Importing or Copying Dashboards


1 comment

  • Avatar
    Test M3

    I had this same problem earlier today; 500 internal server error when trying to import a dashboard that was exported to a .dash file via API.  I fixed it with the following:

    You need to be hitting the bulk API endpoint (the standard "api/v1/dashboards" call mis-formats widgets upon import):

    $webServer = ""

    $importuri = "$($webServer)/api/v1/dashboards/import/bulk"
    Then get the content of your file:
    $Dashboard = "C:\Sisense\Path\To\Your\Dashboard.dash"
    $FileContent = (Get-Content -Path $Dashboard)
    Next, because you're hitting the bulk API, you need to wrap your dashboard json with square brackets, like so:
    $DashContent = "[" + $FileContent + "]"
    Finally, you can make the API call:
    Invoke-RestMethod -Method Post -Uri $importuri -Headers $head -Body $DashContent -ContentType "application/json"
    The 500 error I was receiving initially was because I had made the Invoke-RestMethod call without the -ContentType parameter.  If you don't specify the "application/json" content type when sending the request, the call gets sent as "application/x-www-form-urlencoded", which returns a 500 error.
    I hope that's helpful!
    ~ Scott
    Comment actions Permalink

Please sign in to leave a comment.