Importing Kibana JSON files using Kibana API call


(Shri Harsha) #1

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?


(Nathan Reese) #2

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

      {
        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 to export and import Kibana saved objects with an API.


(Shri Harsha) #3

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" -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?


(system) #4

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