# Importing Dashboard via CURL fails with 500 error

**URL:** <https://discuss.elastic.co/t/importing-dashboard-via-curl-fails-with-500-error/230421>\
**Category:** Kibana\
**Created:** [April 29, 2020, 6:31pm UTC](https://discuss.elastic.co/t/importing-dashboard-via-curl-fails-with-500-error/230421 "2020-04-29T18:31:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerrac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jerrac/32/52980_2.png) [@jerrac](https://discuss.elastic.co/u/jerrac)\
**Post date:** [April 29, 2020, 6:31pm UTC](https://discuss.elastic.co/t/importing-dashboard-via-curl-fails-with-500-error/230421/1 "2020-04-29T18:31:16Z")

</div>

On my old dev stack I used the beats setup feature to install the example dashboards. That ended up with a bunch I will never use. So now that I'm building an actual test stack, I want to pick and choose which dashboards I import.

I started with this on: [https://github.com/elastic/beats/blob/v7.6.2/metricbeat/module/system/\_meta/kibana/7/dashboard/Metricbeat-host-overview.json](https://github.com/elastic/beats/blob/v7.6.2/metricbeat/module/system/_meta/kibana/7/dashboard/Metricbeat-host-overview.json)

I found the [docs](https://www.elastic.co/guide/en/kibana/current/dashboard-import-api.html) on how to import and tried it out.

The response:

```json
{"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"}

```

In Kibana's logs:

```auto
testelk01_kibana | {"type":"error","@timestamp":"2020-04-29T11:17:53-07:00","tags":[],"pid":6,"level":"error","error":{"message":"Failure attempting to migrate saved object 'Network Traffic (Packets) [Metricbeat System] ECS' - SyntaxError: Unexpected token o in JSON at position 1","name":"Error","stack":"Error: Failure attempting to migrate saved object 'Network Traffic (Packets) [Metricbeat System] ECS' - SyntaxError: Unexpected token o in JSON at position 1\n at 7.0.0 (/usr/share/kibana/src/legacy/core_plugins/kibana/migrations/migrations.js:605:15)\n at tryTransformDoc (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:213:22)\n at migrateProp (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:270:11)\n at applyMigrations (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:172:11)\n at DocumentMigrator.transformAndValidate [as transformDoc] (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:151:43)\n at DocumentMigrator.doc [as migrate] (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:47:19)\n at KibanaMigrator.migrateDocument (/usr/share/kibana/src/core/server/saved_objects/migrations/kibana/kibana_migrator.js:139:34)\n at objects.map.object (/usr/share/kibana/src/core/server/saved_objects/service/lib/repository.js:233:74)\n at Array.map (<anonymous>)\n at SavedObjectsRepository.bulkCreate (/usr/share/kibana/src/core/server/saved_objects/service/lib/repository.js:217:37)\n at SavedObjectsClient.bulkCreate (/usr/share/kibana/src/core/server/saved_objects/service/saved_objects_client.js:46:35)\n at EncryptedSavedObjectsClientWrapper.bulkCreate (/usr/share/kibana/x-pack/plugins/encrypted_saved_objects/server/saved_objects/encrypted_saved_objects_client_wrapper.js:80:89)\n at process._tickCallback (internal/process/next_tick.js:68:7)"},"url":{"protocol":null,"slashes":null,"auth":null,"host":null,"port":null,"hostname":null,"hash":null,"search":null,"query":{},"pathname":"/api/kibana/dashboards/import","path":"/api/kibana/dashboards/import","href":"/api/kibana/dashboards/import"},"message":"Failure attempting to migrate saved object 'Network Traffic (Packets) [Metricbeat System] ECS' - SyntaxError: Unexpected token o in JSON at position 1"}

```

Since I didn't anything like it in the documentation example, I removed this from the end of the dashboard json:

```auto
,
    "version": "6.0.0-rc1-SNAPSHOT"

```

Still ended up with the same error.

My curl command, ran on the same server as Kibana. Removed the dashboard json due to Discourse character limits.

```auto
curl -X POST "http://adminusername:password@localhost:5601/api/kibana/dashboards/import" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
< json of the dashboard, modified as I mentioned above >
'

```

What am I missing?

Is there a UI option for importing that I just haven't found?

Thanks.

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [April 29, 2020, 6:57pm UTC](https://discuss.elastic.co/t/importing-dashboard-via-curl-fails-with-500-error/230421/2 "2020-04-29T18:57:40Z")

</div>

Please follow the steps in our [documentation](https://www.elastic.co/guide/en/beats/metricbeat/current/configuration-dashboards.html) to install the dashboard using Metricbeat itself.

---

<div class="post-metadata">

**Author:** ![jerrac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jerrac/32/52980_2.png) [@jerrac](https://discuss.elastic.co/u/jerrac)\
**Post date:** [April 29, 2020, 7:15pm UTC](https://discuss.elastic.co/t/importing-dashboard-via-curl-fails-with-500-error/230421/3 "2020-04-29T19:15:26Z")

</div>

> [@Luca\_Belluccini](#):
>
> Please follow the steps in our [documentation](https://www.elastic.co/guide/en/beats/metricbeat/current/configuration-dashboards.html) to install the dashboard using Metricbeat itself.

That isn't what I want to do. I only want to install the specific dashboards I will use. Using beats setup will not do that.

---

<div class="post-metadata">

**Author:** ![jerrac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jerrac/32/52980_2.png) [@jerrac](https://discuss.elastic.co/u/jerrac)\
**Post date:** [April 29, 2020, 9:03pm UTC](https://discuss.elastic.co/t/importing-dashboard-via-curl-fails-with-500-error/230421/4 "2020-04-29T21:03:26Z")

</div>

I could just push them all in, then figure out how to delete the ones I don't use.

I'd still like to figure out how to push via the import api, especially if I find non-Elastic created dashboards to import. 🙂

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [April 29, 2020, 9:22pm UTC](https://discuss.elastic.co/t/importing-dashboard-via-curl-fails-with-500-error/230421/5 "2020-04-29T21:22:20Z")

</div>

The files cannot imported as-is, as they're pre-processed by Metricbeat.

This is the procedure which works and it's the "official" one:

1. Grab Metricbeat 7.6.2
2. Go to the `kibana/7/dashboard` directory
3. Move all the files of the dashboards you do not want in a sub directory
4. Run, depending on your OS, the following command:

```auto
   ./metricbeat setup --dashboards \
-E 'setup.dashboards.enabled=true' \
-E 'setup.kibana.host=https://<kibana host>:<kibana port>' \
-E 'setup.kibana.username=elastic' \
-E 'setup.kibana.password=<password>' \
-E 'output.elasticsearch.enabled=false' \
-E 'output.console.enabled=true'

```

You can pass other parameters (see [here](https://www.elastic.co/guide/en/beats/metricbeat/current/setup-kibana-endpoint.html) and [here](https://www.elastic.co/guide/en/beats/metricbeat/current/configuration-dashboards.html))

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [April 29, 2020, 9:27pm UTC](https://discuss.elastic.co/t/importing-dashboard-via-curl-fails-with-500-error/230421/6 "2020-04-29T21:27:29Z")

</div>

> [@jerrac](#):
>
> I'd still like to figure out how to push via the import api, especially if I find non-Elastic created dashboards to import.

The command you're using is correct, but it seems the dashboards we have bundled with Beats are pre-processed by the Beat binary.

To import:

```auto
curl -s -XPOST https://<kibana:port>/api/kibana/dashboards/import -d "@dashboard.json" -u elastic:password -Hkbn-xsrf:true -Hcontent-type:application/json

```

To export:

```auto
curl -s https://<kibana:port>/api/kibana/dashboards/export?dashboard=<dashboard-id> -u elastic:password -o dashboard.json

```

---

<div class="post-metadata">

**Author:** ![jerrac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jerrac/32/52980_2.png) [@jerrac](https://discuss.elastic.co/u/jerrac)\
**Post date:** [April 29, 2020, 10:50pm UTC](https://discuss.elastic.co/t/importing-dashboard-via-curl-fails-with-500-error/230421/7 "2020-04-29T22:50:15Z")

</div>

> [@Luca\_Belluccini](#):
>
> The command you're using is correct, but it seems the dashboards we have bundled with Beats are pre-processed by the Beat binary.

Ah. Well, so much for my idea of picking and choosing...

Thanks. I'll do it the official way.

---

<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:** [May 27, 2020, 10:50pm UTC](https://discuss.elastic.co/t/importing-dashboard-via-curl-fails-with-500-error/230421/8 "2020-05-27T22:50:16Z")

</div>

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