# Error in custom plugin of Kibana

**URL:** <https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066>\
**Category:** Kibana\
**Created:** [June 28, 2019, 2:50pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066 "2019-06-28T14:50:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [June 28, 2019, 2:50pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/1 "2019-06-28T14:50:34Z")

</div>

hi team,  
Please, help with issue. Getting error while making a POST/PUT requests from custom plugin from browser to elastic index:

```
status: 401,
 displayName: 'AuthenticationException',
 message:
'[security_exception] missing authentication token for REST request [/_bulk?0=&1=&2=&3=], with { header={ WWW-Authenticate="Basic realm=\\"security\\" charset=\\"UTF- 8\\"" } }',
 path: '/_bulk',
 query:
  { '0': [Object], '1': [Object], '2': [Object], '3': [Object] },
 body: { error: [Object], status: 401 },
 statusCode: 401,
 response:
‘{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request [/_bulk?0=&1=&2=&3=]","header":{"WWW-Authenticate":"Basic realm=\\"security\\" charset=\\"UTF-8\\""}}],"type":"security_exception","reason":"missing authentication token for REST request [/_bulk?0=&1=&2=&3=]","header":{"WWW-Authenticate":"Basic realm=\\"security\\" charset=\\"UTF-8\\""}},"status":401}',
 wwwAuthenticateDirective: 'Basic realm="security" charset="UTF-8"',
 toString: [Function],
 toJSON: [Function],
 isBoom: true,
 isServer: false,
 data: null,
 output: { statusCode: 401, payload: [Object], headers: [Object] },
```

---

<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:** [June 28, 2019, 3:43pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/2 "2019-06-28T15:43:48Z")

</div>

Few more follow up questions: what version of the stack are you on ? License level? Is there a proxy in btw Kibana and ES .

Thanks  
Rashmi

---

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [June 29, 2019, 7:26am UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/3 "2019-06-29T07:26:06Z")

</div>

I use ES 6.7.0 with trial x-pack license. There is no proxy btw them.

---

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [July 1, 2019, 7:44am UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/4 "2019-07-01T07:44:35Z")

</div>

team, any help here?

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [July 1, 2019, 2:11pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/5 "2019-07-01T14:11:17Z")

</div>

Hey @masterThomas,

How are you making the request from the browser to elasticsearch? Is the browser making the request directly to ES, or is it going through the Kibana server to proxy the request to ES?

---

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [July 1, 2019, 3:30pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/6 "2019-07-01T15:30:09Z")

</div>

it goes through Kibana server : client goes to endpoint, endpoint makes PUT or POST or DELETE request and then makes records, but in my case it does not record with the error " missing authentication token for REST request [/\_bulk] "

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [July 1, 2019, 4:01pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/7 "2019-07-01T16:01:43Z")

</div>

Can you share how you're making the request to Kibana from the kibana server on behalf of the end user?

---

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [July 1, 2019, 4:53pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/8 "2019-07-01T16:53:55Z")

</div>

i used Postman to make requests. i just send my JSON to custom endpoint to post or update changes and then get the error.

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [July 1, 2019, 5:06pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/9 "2019-07-01T17:06:39Z")

</div>

You should use Kibana's built-in Elasticsearch client to perform requests to ES. See [Communicating with Elasticsearch](https://www.elastic.co/guide/en/kibana/7.2/development-elasticsearch.html) for more details. If you're looking to make requests on behalf of the end user, then you'll want to use the `callWithRequest` described in that link.

---

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [July 1, 2019, 6:09pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/10 "2019-07-01T18:09:42Z")

</div>

i already use `callWithRequest` in my endpoint. so this error is with `callWithRequest` method.  
I made my endpoint with settings described in that link. so i use`callWithRequest` and get the error in this topic

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [July 1, 2019, 6:32pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/11 "2019-07-01T18:32:39Z")

</div>

Is your plugin code available on github? I really need to see a code sample to help out any further.

---

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [July 2, 2019, 8:41am UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/12 "2019-07-02T08:41:10Z")

</div>

i commited my code on github with reference [kibana plugin github](https://github.com/webmasterThomas/rtable.git)

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [July 2, 2019, 9:40am UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/13 "2019-07-02T09:40:58Z")

</div>

Thanks @masterThomas. I see it doesn't have the `public` directory/code, so I won't be able to run this, but the code itself looks correct on the surface.

How do you have Kibana and Elasticsearch configured? Can you post your `kibana.yml` and `elasticsearch.yml` configuration, redacting any sensitive information such as passwords?

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [July 2, 2019, 9:51am UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/14 "2019-07-02T09:51:00Z")

</div>

are all `bulk` requests failing, or are just one/some of them failing?

---

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [July 3, 2019, 8:12am UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/16 "2019-07-03T08:12:53Z")

</div>

all bulk request are failing. I posted my config files on github: [kibana.yml](https://github.com/webmasterThomas/rtable/blob/master/kibana.yml) and [elasticsearch.yml](https://github.com/webmasterThomas/rtable/blob/master/elasticsearch.yml)

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [July 3, 2019, 10:41am UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/17 "2019-07-03T10:41:00Z")

</div>

Thanks for the update, your configuration looks fine on the surface as well. Are you in a position to share the complete plugin code on github? The `public` folder is missing at the very least, so I'm not able to download and run this to help diagnose problems.

---

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [July 3, 2019, 11:22am UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/18 "2019-07-03T11:22:32Z")

</div>

Unfortunately, im not able to share my code. Can we use teamviewer session or kind of that?

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [July 3, 2019, 1:47pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/19 "2019-07-03T13:47:42Z")

</div>

Sent you a DM

---

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [July 9, 2019, 1:00pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/20 "2019-07-09T13:00:39Z")

</div>

Hi Larry, many thanks for your help. I resolved this strange issue. Hope, it will not return.

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [July 9, 2019, 1:10pm UTC](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066/21 "2019-07-09T13:10:43Z")

</div>

For anyone else following along, make sure your bulk requests have a `body` property:

🚫 BAD

```auto
const bulkRequests = [
  {"update": { ... } },
  { ... },
  {"index": { ... } },
  { ... } 
];

await callWithRequest(request, 'bulk', bulkRequest);

```

* * *

✅ GOOD

```auto
const bulkRequests = [
  {"update": { ... } },
  { ... },
  {"index": { ... } },
  { ... } 
];

await callWithRequest(request, 'bulk', { body: bulkRequests });

```

[Next page](https://discuss.elastic.co/t/error-in-custom-plugin-of-kibana/188066.md?page=2)
