Import a saved dashboard into Elasticsearch using Java

I am trying to import a saved dashboard into Elasticsearch using HttpURLConnection.

I can successfully execute the following taken from the saved objects api example in Elasticsearch documentation.

$ curl -X POST api/saved_objects/_import?createNewCopies=true -H "kbn-xsrf: true" --form file=@file.ndjson (with appropriate changes to url for my host)

But I cannot manage to do the same in java code with a POST using HttpURLConnection.

Can any give me an example of how to do what above curl command does in java.

Thanks for you help.

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