I'm trying to reuse the dashboard i have on another index. I downloaded the file from saved objects which is in ndjson format and edited following fields
index name, index id(uuid), dashboard name and dashboard id(uuid)
and uploading it with REST API.
curl -X POST "localhost:5601/api/kibana/dashboards/import?exclude=index-pattern" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d @dashboard.json
This is the [part of] dashboard.json
{
"objects":[
{"attributes":{"description":"index: one_8apr_1","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"Overall Conversations-1","uiStateJSON":"{}","version":1,"visState":"{\"title\":\"Overall Conversations\",\"type\":\"metric\",\"params\":{\"metric\":{\"percentageMode\":false,\"useRanges\":false,\"colorSchema\":\"Green to Red\",\"metricColorMode\":\"None\",\"colorsRange\":[{\"type\":\"range\",\"from\":0,\"to\":10000}],\"labels\":{\"show\":true},\"invertColors\":false,\"style\":{\"bgFill\":\"#000\",\"bgColor\":false,\"labelColor\":false,\"subText\":\"\",\"fontSize\":60}},\"dimensions\":{\"metrics\":[{\"type\":\"vis_dimension\",\"accessor\":0,\"format\":{\"id\":\"number\",\"params\":{}}}]},\"addTooltip\":true,\"addLegend\":false,\"type\":\"metric\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"cardinality\",\"schema\":\"metric\",\"params\":{\"field\":\"conversation_id.keyword\",\"customLabel\":\" \"}}]}"},"id":"dd7337d0-797d-11ea-b521-59fdf02d9efc","migrationVersion":{"visualization":"7.4.2"},"references":[{"id":"af87feb0-7963-11ea-b521-59fdf02d9efc","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"}],"type":"visualization","updated_at":"2020-04-20T11:26:46.370Z","version":"WzY4OCwxXQ=="},
{"attributes":{"description":"index: one_8apr_1","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"Successful Conversations-1","uiStateJSON":"{}","version":1,"visState":"{\"aggs\":[{\"enabled\":true,\"id\":\"1\",\"params\":{\"customBucket\":{\"enabled\":true,\"id\":\"1-bucket\",\"params\":{\"filters\":[{\"input\":{\"language\":\"kuery\",\"query\":\"resolution_response:YES\"},\"label\":\"\"}]},\"schema\":{\"aggFilter\":[],\"editor\":false,\"group\":\"none\",\"max\":null,\"min\":0,\"name\":\"bucketAgg\",\"params\":[],\"title\":\"Bucket agg\"},\"type\":\"filters\"},\"customLabel\":\" \",\"customMetric\":{\"enabled\":true,\"id\":\"1-metric\",\"params\":{\"customLabel\":\" \"},\"schema\":{\"aggFilter\":[\"!top_hits\",\"!percentiles\",\"!percentile_ranks\",\"!median\",\"!std_dev\",\"!sum_bucket\",\"!avg_bucket\",\"!min_bucket\",\"!max_bucket\",\"!derivative\",\"!moving_avg\",\"!serial_diff\",\"!cumulative_sum\",\"!geo_bounds\",\"!geo_centroid\"],\"editor\":false,\"group\":\"none\",\"max\":null,\"min\":0,\"name\":\"metricAgg\",\"params\":[],\"title\":\"Metric agg\"},\"type\":\"count\"}},\"schema\":\"metric\",\"type\":\"sum_bucket\"}],\"params\":{\"addLegend\":false,\"addTooltip\":true,\"dimensions\":{\"metrics\":[{\"accessor\":0,\"format\":{\"id\":\"number\",\"params\":{}},\"type\":\"vis_dimension\"}]},\"metric\":{\"colorSchema\":\"Green to Red\",\"colorsRange\":[{\"from\":0,\"to\":10000,\"type\":\"range\"}],\"invertColors\":false,\"labels\":{\"show\":true},\"metricColorMode\":\"None\",\"percentageMode\":false,\"style\":{\"bgColor\":false,\"bgFill\":\"#000\",\"fontSize\":60,\"labelColor\":false,\"subText\":\"\"},\"useRanges\":false},\"type\":\"metric\"},\"title\":\"Successful Conversations\",\"type\":\"metric\"}"},"id":"2b0af950-7a60-11ea-b521-59fdf02d9efc","migrationVersion":{"visualization":"7.4.2"},"references":[{"id":"af87feb0-7963-11ea-b521-59fdf02d9efc","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"}],"type":"visualization","updated_at":"2020-04-20T11:26:46.370Z","version":"WzY4OSwxXQ=="},
{"objects":[{"id":"dd7337d0-797d-11ea-b521-59fdf02d9efc","type":"visualization","error":{"statusCode":409,"message":"version conflict, document already exists"}},{"id":"2b0af950-7a60-11ea-b521-59fdf02d9efc","type":"visualization","error":{"statusCode":409,"message":"version conflict, document already exists"}}
also it is giving me 400 Bad request when i dont have any issue with the json file uploaded but the dashboard is getting created successfully.
{"error":{"message":"Unsupported saved object type: 'undefined': Bad Request","statusCode":400,"error":"Bad Request"}}
what could be the reason? When i pass ndjson file as input to curl command it is still giving the same output with same errors.