# Unable to export Kibana dashboard using API

**URL:** https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941
**Category:** Kibana
**Created:** [September 8, 2022, 4:37am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941 "2022-09-08T04:37:51Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![rt\_888](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rt_888/32/110632_2.png) [@rt\_888](https://discuss.elastic.co/u/rt_888)
#### Post date: [September 8, 2022, 4:37am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/1 "2022-09-08T04:37:51Z")

</div>

// curl -X POST “[http://localhost:5601/api/saved\_objects/\_export”](http://localhost:5601/api/saved_objects/_export%E2%80%9D) -H ‘kbn-xsrf: true’ -H ‘Content-Type: application/json’ -d’ { “type”: “index-pattern” } ‘

I use this as to export my dashboard but i get the error "Incorrect HTTP method for uri .......and method [POST], allowed: [DELETE, HEAD, GET, PUT]",  
"status": 405

Any idea to fix this, thank youuu

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [September 8, 2022, 5:50am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/2 "2022-09-08T05:50:46Z")

</div>

Welcome to our community! 😃

Did you try replacing `POST` with `GET`?

---

<div class="post-metadata">

### Author: ![rt\_888](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rt_888/32/110632_2.png) [@rt\_888](https://discuss.elastic.co/u/rt_888)
#### Post date: [September 8, 2022, 5:57am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/3 "2022-09-08T05:57:27Z")

</div>

I just tried and it still gives the error. it shows "type": "illegal\_argument\_exception", "reason": """request [GET /"[https://localhost/api/saved\_objects/\_export”](https://localhost/api/saved_objects/_export%E2%80%9D)] does not support having a body"""

---

<div class="post-metadata">

### Author: ![rt\_888](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rt_888/32/110632_2.png) [@rt\_888](https://discuss.elastic.co/u/rt_888)
#### Post date: [September 8, 2022, 6:04am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/4 "2022-09-08T06:04:45Z")

</div>

I forget to mention. Both of elasticsearch and kibana running on version 8.3.3 . I run both of the services on docker

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [September 8, 2022, 6:19am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/5 "2022-09-08T06:19:28Z")

</div>

Hi @rt_888

[This](https://www.elastic.co/guide/en/kibana/current/saved-objects-api-export.html) page gives the proper syntax.

So far your examples above have not been correct.

I just ran this

```auto
hyperion:sbrown$ curl -X POST "http://localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '
{
  "type": "index-pattern"
}'

```

And it worked fine

It tried to run yours you are using back quotes not normal quotes looks like your cut-n-past is using smart quotes or something not normal quotes `”` vs `"`

```auto
 curl -X POST “http://localhost:5601/api/saved_objects/_export” -H ‘kbn-xsrf: true’ -H ‘Content-Type: application/json’ -d’ { “type”: “index-pattern” } ‘

```

if I fix all the quotes... it works fine

```auto
curl -X POST "http://localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'{ "type": "index-pattern" }'

```

---

<div class="post-metadata">

### Author: ![rt\_888](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rt_888/32/110632_2.png) [@rt\_888](https://discuss.elastic.co/u/rt_888)
#### Post date: [September 8, 2022, 6:47am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/6 "2022-09-08T06:47:33Z")

</div>

Hello @stephenb, Are we using curl -X here for calling Kibana API? Do we need to add curl -X too? I got error with " Incorrect HTTP method for uri"

P.S : Sorry, I am really new to working with API request and ELK stack.

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [September 8, 2022, 6:50am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/7 "2022-09-08T06:50:51Z")

</div>

> [@stephenb](#):
>
> ```auto
> curl -X POST "http://localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '
> {
> "type": "index-pattern"
> }'
> 
> ```

The documents give you the _ **exact syntax** _ but I think you are cut-n-paste with smart quotes which is causing you issues..

---

<div class="post-metadata">

### Author: ![rt\_888](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rt_888/32/110632_2.png) [@rt\_888](https://discuss.elastic.co/u/rt_888)
#### Post date: [September 8, 2022, 8:25am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/10 "2022-09-08T08:25:03Z")

</div>

So the response are the details of the saved objects from this request.

For the below request is it for export the data view saved objects? do I need to specifiy the api key? If yes, is it in JSON or Base64?

`$ curl -X POST api/saved_objects/_export -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d ' { "type": "index-pattern" }'`

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [September 8, 2022, 2:29pm UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/11 "2022-09-08T14:29:41Z")

</div>

Lets back up a bit.

What version of the stack are you on?

And what are you actually trying to accomplish?

And yes if your cluster has security enabled (authentication) you will need to pass those  
either using the `-u username:password` flag or an API Key which you can rad about [here](https://www.elastic.co/guide/en/kibana/current/api-keys.html)

---

<div class="post-metadata">

### Author: ![rt\_888](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rt_888/32/110632_2.png) [@rt\_888](https://discuss.elastic.co/u/rt_888)
#### Post date: [September 8, 2022, 4:16pm UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/12 "2022-09-08T16:16:28Z")

</div>

The version of the Elastic and Kibana are on 8.3.3. I am trying to export the dashboard from one machine to another machine which also run the same version of elk stack.

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [September 8, 2022, 5:35pm UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/13 "2022-09-08T17:35:33Z")

</div>

and you want to do it via the API then you are on the right track... you need to decide if you are going to use basic auth or API Key.

of course it is very Simple to just do it through the Kibana UI -\> Stack Management -\> Saved Objects..

---

<div class="post-metadata">

### Author: ![rt\_888](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rt_888/32/110632_2.png) [@rt\_888](https://discuss.elastic.co/u/rt_888)
#### Post date: [September 9, 2022, 2:03am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/14 "2022-09-09T02:03:39Z")

</div>

Thanks @stephenb. I try with the basic auth and with API. I am a bit confused. Once I already exported the dashboard to another machine. The client machine which supposed to recieve the dashboard showing that it got the saved object file, but the object file is empty. Does it mean i also need to have the same index file for the dashboard?

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [September 9, 2022, 2:31am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/15 "2022-09-09T02:31:34Z")

</div>

You need to understand that an object like a dashboard has many dependent objects.

That is why I would start with the UI first to test export./ Import.

You also need to understand

`includeReferencesDeep`

As shown in the example

> Export a specific saved object and it’s related objects :

```auto
$ curl -X POST api/saved_objects/_export -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '
{
  "objects": [
    {
      "type": "dashboard",
      "id": "be3733a0-9efe-11e7-acb3-3dab96693fab"
    }
  ],
  "includeReferencesDeep": true
}'

```

> [@rt\_888](#):
>
> The client machine which supposed to recieve the dashboard showing that it got the saved object file, but the object file is empty.

I don't know what that means...

Again if you are new to all this I would use the Kibana UI.

---

<div class="post-metadata">

### Author: ![rt\_888](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rt_888/32/110632_2.png) [@rt\_888](https://discuss.elastic.co/u/rt_888)
#### Post date: [September 9, 2022, 3:26am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/16 "2022-09-09T03:26:49Z")

</div>

Thanks a lot @stephenb 😄 . Yes I did the same method and resolve by adding index to another machine too so I can view the exported dashboard

---

<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: [October 7, 2022, 3:27am UTC](https://discuss.elastic.co/t/unable-to-export-kibana-dashboard-using-api/313941/17 "2022-10-07T03:27:20Z")

</div>

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