# How to get URL data to use with server.inject in the dev mode?

**URL:** <https://discuss.elastic.co/t/how-to-get-url-data-to-use-with-server-inject-in-the-dev-mode/148864>\
**Category:** Kibana\
**Created:** [September 17, 2018, 5:16pm UTC](https://discuss.elastic.co/t/how-to-get-url-data-to-use-with-server-inject-in-the-dev-mode/148864 "2018-09-17T17:16:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trex](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trex/32/34230_2.png) [@trex](https://discuss.elastic.co/u/trex)\
**Post date:** [September 17, 2018, 5:16pm UTC](https://discuss.elastic.co/t/how-to-get-url-data-to-use-with-server-inject-in-the-dev-mode/148864/1 "2018-09-17T17:16:12Z")

</div>

**Kibana v6.2.4**

In the dev mode, Kibana URL contains a random word which is changed after a restart, for example, `poj` word here

```
http://localhost:5601/poj/app/myplugin#/?_g=()

```

How to get the word in a custom plugin server-side code?

* * *

In my Kibana plugin, I use `server.inject()`

```
async function logData(attributes) {
  const resp = await server.inject({
    method: 'PUT',
    url: '/api/myplugin/alarm',
    headers: {
      'kbn-xsrf': 'reporting',
    },
    payload: {
      attributes,
    },
  });

  ... do stuff
}

```

to query the plugin API route from the server code

```
  server.route({
    method: ['PUT'],
    path: '/api/myplugin/alarm/{id?}',
    config: {
      validate: {
        params: {
          id: Joi.string(),
        },
        payload: {
          attributes: Joi.object().required(),
        },
      },
    },
    handler: async function (req, reply) {
    ... do stuff

```

And it works when I run Kibana in the normal mode. But when I run it in the dev mode `cd kibana && npm start`, I get a raw response with `404 Not Found` in the header:

```
{ raw:
   { res:
      Response {
        domain: [Object],
        ...
        socket: [Object],
        connection: [Object],
        _header: 'HTTP/1.1 404 Not Found\r\nkbn-name: kibana\r\nkbn-version: 6.2.4\r\ncontent-type: application/json; charset=utf-8\r\ncache-control: no-cache\r\ncontent-length: 38\r\nDate: Mon, 17 Sep 2018 16:32:02 GMT\r\nConnection: keep-alive\r\n\r\n',

```

I understand this is because I don't have the random word in the `server.inject()` url.

The related question on Stack Overflow: [https://stackoverflow.com/q/52372513/2393924](https://stackoverflow.com/q/52372513/2393924)

**Update**

The example in the question works! The problem was that in my real code I used a wrong path in the route.

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [September 18, 2018, 5:50pm UTC](https://discuss.elastic.co/t/how-to-get-url-data-to-use-with-server-inject-in-the-dev-mode/148864/2 "2018-09-18T17:50:12Z")

</div>

Hi ,  
Can you try this? Try passing `--no-base-path` in dev to eliminate the random base path.

hope this helps eliminating the issue u r seeing.

Cheers  
Rashmi

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [September 19, 2018, 12:41am UTC](https://discuss.elastic.co/t/how-to-get-url-data-to-use-with-server-inject-in-the-dev-mode/148864/3 "2018-09-19T00:41:11Z")

</div>

Glad u posted the update in your original post .

Cheers  
Rashmi

---

<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:** [October 17, 2018, 12:41am UTC](https://discuss.elastic.co/t/how-to-get-url-data-to-use-with-server-inject-in-the-dev-mode/148864/4 "2018-10-17T00:41:23Z")

</div>

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