kibana/docs/api/saved-objects/resolve_import_errors.asciidoc
Brandon Kobel 769bb657fa
Moving Saved Object APIs from Experimental to Beta (#44140)
* Saved Object APIs, now beta!

* Using Gail's word-choice, thanks Gail!!!
2019-08-28 06:58:12 -07:00

106 lines
4.3 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[[saved-objects-api-resolve-import-errors]]
=== Resolve Import Errors
beta[This functionality is *beta*. It's on track to become a stable, permanent feature of {kib}. Caution should be exercised because it is possible a breaking change to these APIs will occur in a minor version, but well avoid this wherever possible. ]
The resolve import errors API enables you to resolve errors given by the import API by either retrying certain saved objects, overwriting specific saved objects or changing references to different saved objects.
Note: You cannot access this endpoint via the Console in Kibana.
==== Request
`POST /api/saved_objects/_resolve_import_errors`
==== Request body
The request body must be of type multipart/form-data.
`file`::
The same file given to the import API.
`retries`::
(array) A list of `type`, `id`, `replaceReferences` and `overwrite` objects to retry importing. The property `replaceReferences` is a list of `type`, `from` and `to` used to change the object's references.
==== Response body
The response body will have a top level `success` property that indicates
if resolving errors was successful or not as well as a `successCount` indicating how many records are successfully resolved.
In the scenario resolving errors wasn't successful, a top level `errors` array will contain the objects that failed to be resolved.
==== Examples
The following example retries importing a dashboard.
[source,js]
--------------------------------------------------
$ curl -X POST "localhost:5601/api/saved_objects/_resolve_import_errors" -H "kbn-xsrf: true" --form file=@file.ndjson --form retries='[{"type":"dashboard","id":"my-dashboard"}]'
--------------------------------------------------
The `file.ndjson` file would contain the following.
[source,js]
--------------------------------------------------
{"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}}
--------------------------------------------------
A successful call returns a response code of `200` and a response body
containing a JSON structure similar to the following example:
[source,js]
--------------------------------------------------
{
"success": true,
"successCount": 1
}
--------------------------------------------------
The following example resolves errors for a dashboard. This will cause the dashboard to overwrite the existing saved object.
[source,js]
--------------------------------------------------
$ curl -X POST "localhost:5601/api/saved_objects/_resolve_import_errors" -H "kbn-xsrf: true" --form file=@file.ndjson --form retries='[{"type":"dashboard","id":"my-dashboard","overwrite":true}]'
--------------------------------------------------
The `file.ndjson` file would contain the following.
[source,js]
--------------------------------------------------
{"type":"index-pattern","id":"my-pattern","attributes":{"title":"my-pattern-*"}}
{"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}}
--------------------------------------------------
A successful call returns a response code of `200` and a response body
containing a JSON structure similar to the following example:
[source,js]
--------------------------------------------------
{
"success": true,
"successCount": 1
}
--------------------------------------------------
The following example resolves errors for a visualization by replacing the index pattern to another.
[source,js]
--------------------------------------------------
$ curl -X POST "localhost:5601/api/saved_objects/_resolve_import_errors" -H "kbn-xsrf: true" --form file=@file.ndjson --form retries='[{"type":"visualization","id":"my-vis","replaceReferences":[{"type":"index-pattern","from":"missing","to":"existing"}]}]'
--------------------------------------------------
The `file.ndjson` file would contain the following.
[source,js]
--------------------------------------------------
{"type":"visualization","id":"my-vis","attributes":{"title":"Look at my visualization"},"references":[{"name":"ref_0","type":"index-pattern","id":"missing"}]}
--------------------------------------------------
A successful call returns a response code of `200` and a response body
containing a JSON structure similar to the following example:
[source,js]
--------------------------------------------------
{
"success": true,
"successCount": 1
}
--------------------------------------------------