Create visualization and dashboard through Java REST jest client?

Hi may I know if there is a way to create visualization and dashboard through jest client?
I know that there is an experimental saved_objects api but I am not sure how can I access that using Jest client.

Hi Luo. Jest is a community supported application, not one that Elastic supports. But I believe Jest only works with the Elasticsearch REST API, not the Kibana REST API. So I do not think it is possible to access the Kibana Saved Objects API with Jest.

Thanks for the reply! May I know if there is a way to interact with the Kibana REST API through code?

Hi Luo. Sorry, I don't understand. Which code are you asking about?

Hi, I mean is there is way to access the saved object API through Java? I want to create visualization / dashboard programmetically

Visualizations and dashboards are stored as JSON objects which can be retrieved and sent to the Saved Objects API. So I suppose you could use custom code to create and send the JSON objects to the REST API.

Hi, thanks for the reply. I have tried that but it did not work, I am using Jest client but have a custom Action class:

class MyAction extends AbstractAction<JestResult>{

    public String getRestMethodName() {
        return "GET";

    public String getURI() {
        return "/api/saved_objects/visualization/2fb71330-cc18-11ea-ae63-1fb5cc29e565";

Then I do:

Action<JestResult> action = new MyAction();
JestResult result = client.execute( action );
System.err.println("test result");
System.err.println( prettyFormat( result.getJsonString() ) );

The output is:

test result
{"error": "no handler found for uri [/api/saved_objects/visualization/2fb71330-cc18-11ea-ae63-1fb5cc29e565] and method [GET]"}

May I know what I did wrong? Is there some sample code that I can try to play with?

Hi it returned useful info after I change the getURI method to:

    public String getURI() {
        return return "_plugin/kibana/api/saved_objects/dashboard/2fb71330-cc18-11ea-ae63-1fb5cc29e565";

I was missing the _plugin/kibana prefix.

But may I know if there is anywhere I can find guidance about using the API? The Kibana docs is missing many details. e.g. the structure of request body etc..

The request body for visualizations and saved objects vary depending on the visualization type or dashboard. You might find it easiest to create your preferred visualizations and dashboards using Kibana first. Then export the saved objects to JSON files so you can examine the structure of the attributes.

1 Like

Thank you so much, I will have a go!

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