# Import saved objects through API

**URL:** <https://discuss.elastic.co/t/import-saved-objects-through-api/315481>\
**Category:** Kibana\
**Created:** [September 29, 2022, 4:46pm UTC](https://discuss.elastic.co/t/import-saved-objects-through-api/315481 "2022-09-29T16:46:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemmerlin](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hemmerlin](https://discuss.elastic.co/u/hemmerlin)\
**Post date:** [September 29, 2022, 4:46pm UTC](https://discuss.elastic.co/t/import-saved-objects-through-api/315481/1 "2022-09-29T16:46:18Z")

</div>

Hello,

To summarize this post, I'm able to import Kibana **saved objects** using the web UI, but I face some issues importing them using the API.

We use a **dashboard.ndjson** file which is the result of a **saved object** export using the Kibana web UI on port 5601 (_Stack Management / Saved objects / Export objects_).

When I import this file using the Kibana web UI (_Stack Management / Saved objects / Import_), it works well: by clicking "Confirm all changes" in the the dialog box below which shows the index pattern conflicts, the saved objects are imported.

 ![KibanaUI](https://us1.discourse-cdn.com/elastic/original/3X/9/e/9ec9b539237ad9d18baa39b8244c5ac2eefab9a4.png)

When I try to import the same file using the API, by typing the following command, some errors appears related to the same index pattern conflicts than the previous ones (see the image below), but this time the saved objects are not imported:

```auto
curl -X POST localhost:5601/api/saved_objects/_import?createNewCopies=true -H "kbn-xsrf: true" --form file=@dashboard.ndjson

```

 ![KibanaAPI](https://us1.discourse-cdn.com/elastic/original/3X/f/b/fb8bd861b38431f4487da2f3f6661b6c18ee0a52.png)

So using the same **dashboard.ndjson** file, I'm able to import it using the web UI but not using the API. Do you have any idea on how to import it using the API ?

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [October 7, 2022, 9:54pm UTC](https://discuss.elastic.co/t/import-saved-objects-through-api/315481/2 "2022-10-07T21:54:50Z")

</div>

ah right. We can resolve this in UI but not sure what to do with API.

@afharo / @Pierre_Gayvallet any ideas?

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![afharo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/afharo/32/75202_2.png) [@afharo](https://discuss.elastic.co/u/afharo)\
**Post date:** [October 14, 2022, 4:00pm UTC](https://discuss.elastic.co/t/import-saved-objects-through-api/315481/3 "2022-10-14T16:00:32Z")

</div>

After looking closer at the code and screenshots, I believe the UI is simply removing those conflicting saved objects from the list of saved objects to import.

It seems that the selected option for all 3 conflicts is `-- Skip Import --`. AFAIK, the UI code will simply remove those Saved Objects from the list to import, and it will import the rest.

To mimic that behaviour via the API, I guess the app needs to remove those conflicting Saved Objects.

---

<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:** [November 11, 2022, 12:36pm UTC](https://discuss.elastic.co/t/import-saved-objects-through-api/315481/4 "2022-11-11T12:36:12Z")

</div>



---

<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 9, 2022, 12:36pm UTC](https://discuss.elastic.co/t/import-saved-objects-through-api/315481/5 "2022-12-09T12:36:54Z")

</div>

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