# Kibana 6 plugin server/API setup not working

**URL:** <https://discuss.elastic.co/t/kibana-6-plugin-server-api-setup-not-working/117106>\
**Category:** Kibana\
**Created:** [January 25, 2018, 7:04pm UTC](https://discuss.elastic.co/t/kibana-6-plugin-server-api-setup-not-working/117106 "2018-01-25T19:04:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![srbdev](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@srbdev](https://discuss.elastic.co/u/srbdev)\
**Post date:** [January 25, 2018, 7:04pm UTC](https://discuss.elastic.co/t/kibana-6-plugin-server-api-setup-not-working/117106/1 "2018-01-25T19:04:11Z")

</div>

Back in Kibana 4.5.0, I had a plugin acting as a REST API endpoint using the following code:

```
// plugins/plugin_name/index.js
export default function (kibana) {
  const http = require('http');

  return new kibana.Plugin({
    config: Joi => {
      return Joi.object({
        enabled: Joi.boolean().default(true)
      }).default();
    },
    require: ['kibana'],
    init(server, options) {

      server.route({
        method: 'POST',
        path: '...',
        handler: (req, reply) => { ... }
      })
    }
  })
}

// tasks/config/copy.js
installPlugins: {
  options: { mode: true },
  src: [
    'plugins/plugin_name/**'
  ],
  dest: 'build/kibana',
  expand: true
}

```

I then call the API endpoint using the $http module within a visualization. I have ported the code to Kibana 6 and though, in the logs, it says that the plugin's status changed from uninitialized to green - ready, the client returns a 404 when hitting the API endpoint.

I can't seem to find the new way of doing this in the docs, so if anyone has any ideas, let me know! Thank you!

---

<div class="post-metadata">

**Author:** ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)\
**Post date:** [January 25, 2018, 7:32pm UTC](https://discuss.elastic.co/t/kibana-6-plugin-server-api-setup-not-working/117106/2 "2018-01-25T19:32:26Z")

</div>

This code looks like it should work. The only thing I can think of is maybe the client is not using the right path to hit this endpoint. Can you confirm that the client is using the right base for the path it constructs? If the endpoint is defined with the path '/foo/bar/' the client needs to append that to the path Kibana lives at (this path is generated when Kibana starts up).

---

<div class="post-metadata">

**Author:** ![srbdev](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@srbdev](https://discuss.elastic.co/u/srbdev)\
**Post date:** [January 25, 2018, 7:55pm UTC](https://discuss.elastic.co/t/kibana-6-plugin-server-api-setup-not-working/117106/3 "2018-01-25T19:55:35Z")

</div>

Ok that might be it: in plugins/plugin\_name/index.js, I define path to be `/my_path/my_endpoint` and use `/my_path/my_endpoint` for url in the client.

You mean to add `${ kibana.full_path }/my_path/my_endpoint` for it to work? If so, how do I have access to that variable programmatically from the client?

Thanks for the quick reply!

---

<div class="post-metadata">

**Author:** ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)\
**Post date:** [January 25, 2018, 7:57pm UTC](https://discuss.elastic.co/t/kibana-6-plugin-server-api-setup-not-working/117106/4 "2018-01-25T19:57:57Z")

</div>

Yes there is an API to add the basepath:

```
import chrome from 'ui/chrome';

const apiPath = chrome.addBasePath(YOUR_PATH);
```

---

<div class="post-metadata">

**Author:** ![srbdev](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@srbdev](https://discuss.elastic.co/u/srbdev)\
**Post date:** [January 25, 2018, 8:08pm UTC](https://discuss.elastic.co/t/kibana-6-plugin-server-api-setup-not-working/117106/5 "2018-01-25T20:08:18Z")

</div>

Yep, that did the trick. Awesome and thank you so much!

---

<div class="post-metadata">

**Author:** ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)\
**Post date:** [January 25, 2018, 8:13pm UTC](https://discuss.elastic.co/t/kibana-6-plugin-server-api-setup-not-working/117106/6 "2018-01-25T20:13:40Z")

</div>

Awesome, glad to hear.

---

<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:** [February 22, 2018, 8:14pm UTC](https://discuss.elastic.co/t/kibana-6-plugin-server-api-setup-not-working/117106/7 "2018-02-22T20:14:13Z")

</div>

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