# Create visualization and dashboard through Java REST jest client?

**URL:** <https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566>\
**Category:** Kibana\
**Tags:** language-clients\
**Created:** [August 3, 2020, 12:49pm UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566 "2020-08-03T12:49:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Redcxx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redcxx/32/73872_2.png) [@Redcxx](https://discuss.elastic.co/u/Redcxx)\
**Post date:** [August 3, 2020, 12:49pm UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566/1 "2020-08-03T12:49:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [August 3, 2020, 9:43pm UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566/2 "2020-08-03T21:43:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Redcxx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redcxx/32/73872_2.png) [@Redcxx](https://discuss.elastic.co/u/Redcxx)\
**Post date:** [August 4, 2020, 8:28am UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566/3 "2020-08-04T08:28:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [August 13, 2020, 4:55pm UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566/4 "2020-08-13T16:55:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Redcxx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redcxx/32/73872_2.png) [@Redcxx](https://discuss.elastic.co/u/Redcxx)\
**Post date:** [August 13, 2020, 4:59pm UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566/5 "2020-08-13T16:59:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [August 13, 2020, 6:08pm UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566/6 "2020-08-13T18:08:18Z")

</div>

Visualizations and dashboards are stored as JSON objects which can be retrieved and sent to the [Saved Objects API](https://www.elastic.co/guide/en/kibana/current/saved-objects-api.html). So I suppose you could use custom code to create and send the JSON objects to the REST API.

---

<div class="post-metadata">

**Author:** ![Redcxx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redcxx/32/73872_2.png) [@Redcxx](https://discuss.elastic.co/u/Redcxx)\
**Post date:** [August 14, 2020, 8:44am UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566/7 "2020-08-14T08:44:34Z")

</div>

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:

```auto
class MyAction extends AbstractAction<JestResult>{

    @Override
    public String getRestMethodName() {
        return "GET";
    }

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

```

Then I do:

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

```

The output is:

```auto
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?

---

<div class="post-metadata">

**Author:** ![Redcxx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redcxx/32/73872_2.png) [@Redcxx](https://discuss.elastic.co/u/Redcxx)\
**Post date:** [August 14, 2020, 2:30pm UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566/8 "2020-08-14T14:30:20Z")

</div>

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

```auto
@Override
    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..

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [August 14, 2020, 3:54pm UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566/9 "2020-08-14T15:54:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Redcxx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redcxx/32/73872_2.png) [@Redcxx](https://discuss.elastic.co/u/Redcxx)\
**Post date:** [August 14, 2020, 6:19pm UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566/10 "2020-08-14T18:19:07Z")

</div>

Thank you so much, I will have a go!

---

<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:** [September 11, 2020, 6:19pm UTC](https://discuss.elastic.co/t/create-visualization-and-dashboard-through-java-rest-jest-client/243566/11 "2020-09-11T18:19:10Z")

</div>

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