Problem importing saved_objects using api

I want to export saved_objects and use the output file to import the objects in another space.
The export goes well, the file can be imported by hand in the ELK GUI, but when I try importing it using the just exported file I get the following error:

{"StatusCode: 400","error":"Bad request","message":"[request body.file]: expected value of type: [Stream] but got [string]"}

The commands I use are:

curl -u '<user>:<password>' -X POST <url>:<port>/s/<source space>/api/saved_objects/_export -H 'kbn-xsrf: true' -H 'Content-type: application/json' -d'
{ "type": "dashboard",
  "includeReferencesDeep": true,
  "excludeReportDetails": true
}' > file.ndjson
curl -u '<user>:<password>' -X POST <url>:<port>/s/<dest space>/api/saved_objects/_import -H 'kbn-xsrf: true' --form file=file.ndjson



To whom it may concern: the problem is solved. In the import command I needed a -@- before the filename:

curl -u '<user>:<password>' -X POST <url>:<port>/s/<dest space>/api/saved_objects/_import -H 'kbn-xsrf: true' --form file=@file.ndjson

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