# Problem importing saved\_objects using api

**URL:** <https://discuss.elastic.co/t/problem-importing-saved-objects-using-api/292304>\
**Category:** Elasticsearch\
**Created:** [December 17, 2021, 12:10pm UTC](https://discuss.elastic.co/t/problem-importing-saved-objects-using-api/292304 "2021-12-17T12:10:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fkoene](https://avatars.discourse-cdn.com/v4/letter/f/dc4da7/32.png) [@fkoene](https://discuss.elastic.co/u/fkoene)\
**Post date:** [December 17, 2021, 12:10pm UTC](https://discuss.elastic.co/t/problem-importing-saved-objects-using-api/292304/1 "2021-12-17T12:10:38Z")

</div>

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:

```auto
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

```

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

```

Thanks,

Fred

---

<div class="post-metadata">

**Author:** ![fkoene](https://avatars.discourse-cdn.com/v4/letter/f/dc4da7/32.png) [@fkoene](https://discuss.elastic.co/u/fkoene)\
**Post date:** [December 22, 2021, 4:18pm UTC](https://discuss.elastic.co/t/problem-importing-saved-objects-using-api/292304/2 "2021-12-22T16:18:53Z")

</div>

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

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

```

---

<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:** [January 19, 2022, 4:19pm UTC](https://discuss.elastic.co/t/problem-importing-saved-objects-using-api/292304/3 "2022-01-19T16:19:44Z")

</div>

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