# Importing Kibana JSON files using Kibana API call

**URL:** https://discuss.elastic.co/t/importing-kibana-json-files-using-kibana-api-call/155344
**Category:** Kibana
**Created:** [November 5, 2018, 6:46am UTC](https://discuss.elastic.co/t/importing-kibana-json-files-using-kibana-api-call/155344 "2018-11-05T06:46:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![shriharsha](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@shriharsha](https://discuss.elastic.co/u/shriharsha)
#### Post date: [November 5, 2018, 6:46am UTC](https://discuss.elastic.co/t/importing-kibana-json-files-using-kibana-api-call/155344/1 "2018-11-05T06:46:15Z")

</div>

I have JSON file which has an Index and its corresponding Searches, Visualizations and Dashbords.

Now I want to import that JSON file in to the kibana using the Import API call. I used the following api call to import a JSON file named X.  
`curl -u elastic:changeme -k -XPOST -H 'Content-Type: application/json' 'http://localhost:5601/api/kibana/dashboards/import' -H "kbn-xsrf: true" -d @Cloudtrail.json`

It is showing following error:  
`{"statusCode":400,"error":"Bad Request","message":"\"value\" must be an object","validation":{"source":"payload","keys":["value"]}}`

So what to do now? How to reslove this error?

---

<div class="post-metadata">

### Author: ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)
#### Post date: [November 5, 2018, 2:25pm UTC](https://discuss.elastic.co/t/importing-kibana-json-files-using-kibana-api-call/155344/2 "2018-11-05T14:25:00Z")

</div>

How was the Kibana JSON export file created?

Unfortunately, the dashboards/import API is only compatible with files made from the dashboards/export API. The payload for the dashboards/import API needs to look something like this [https://github.com/elastic/kibana/blob/master/src/core\_plugins/kibana/server/lib/import/import\_dashboards.test.js#L31](https://github.com/elastic/kibana/blob/master/src/core_plugins/kibana/server/lib/import/import_dashboards.test.js#L31)

```auto
      {
        version: '6.0.0',
        objects: [
          { id: 'dashboard-01', type: 'dashboard', attributes: { panelJSON: '{}' } },
          { id: 'panel-01', type: 'visualization', attributes: { visState: '{}' } },
        ]
      }

```

Try using the the [Saved objects API](https://www.elastic.co/guide/en/kibana/6.4/saved-objects-api.html) to export and import Kibana saved objects with an API.

---

<div class="post-metadata">

### Author: ![shriharsha](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@shriharsha](https://discuss.elastic.co/u/shriharsha)
#### Post date: [November 6, 2018, 10:30am UTC](https://discuss.elastic.co/t/importing-kibana-json-files-using-kibana-api-call/155344/3 "2018-11-06T10:30:02Z")

</div>

Thanks for responding.  
I created the JSON file with Saved Objects bulk get api call. My API Call is as follows:  
curl -X POST "[http://localhost:5601/api/saved\_objects/\_bulk\_get](http://localhost:5601/api/saved_objects/_bulk_get)" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'  
[  
{  
"type": "index-pattern",  
"id": "4afc1210-cb86-11e8-a511-856ad0f7e2c7"  
}  
]  
' \> Cloudtrail.json

Then I used bulk created api call to import this JSON file as follows:  
`curl -X POST "http://localhost:5601/api/saved_objects/_bulk_create" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d @Cloudtrail.json`

It is showing the following error:  
`{"statusCode":400,"error":"Bad Request","message":"\"value\" must be an array","validation":{"source":"payload","keys":["value"]}}`

So what to do now?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 4, 2018, 10:30am UTC](https://discuss.elastic.co/t/importing-kibana-json-files-using-kibana-api-call/155344/4 "2018-12-04T10:30:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
