# Call External REST API from Kibana Plugin - Server side

**URL:** <https://discuss.elastic.co/t/call-external-rest-api-from-kibana-plugin-server-side/173221>\
**Category:** Kibana\
**Created:** [March 20, 2019, 8:34pm UTC](https://discuss.elastic.co/t/call-external-rest-api-from-kibana-plugin-server-side/173221 "2019-03-20T20:34:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Soules](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_soules/32/42468_2.png) [@Mark\_Soules](https://discuss.elastic.co/u/Mark_Soules)\
**Post date:** [March 20, 2019, 8:34pm UTC](https://discuss.elastic.co/t/call-external-rest-api-from-kibana-plugin-server-side/173221/1 "2019-03-20T20:34:16Z")

</div>

Hi,

As the title states, I would like to make a request to an external API (that I don't own) on the server side of my plugin. The API I'm querying requires that I pass the key, certificate, and CA to it however, and whenever I do, my plugin gets disabled for some reason.

I don't know if this is a good way of doing this external call, and I haven't been able to get the call to work on the front-end as described in [How to call external web service from Kibana Plugin?](https://discuss.elastic.co/t/how-to-call-external-web-service-from-kibana-plugin/50184) as well as [How to call external web service from Kibana Plugin?](https://discuss.elastic.co/t/call-external-rest-api-from-kibana-plugin/110541)

I need to get a large amount of data from this API and hopefully, eventually, put it into elasticsearch, all through this plugin if possible. For now I'd be happy with just a successful call, back-end or front. (working on Kibana 6.2.4)

Here's an example:

```auto
import request from 'request';
import fs from 'fs';

var options = {
  uri: 'external-api-path.com:port',
  method: "POST"
  key: fs.readFileSync('path/to/key.pem'),
  cert: fs.readFileSync('path/to/cert.pem'),
  ca: fs.readFileSync('path/to/ca.pem')
}
request(options, function callback(err, response, body) {
  if (err) {
    reply(err);
  }
  reply(body);
});

```

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [March 20, 2019, 9:32pm UTC](https://discuss.elastic.co/t/call-external-rest-api-from-kibana-plugin-server-side/173221/2 "2019-03-20T21:32:15Z")

</div>

What's the error message you're getting in this example?

---

<div class="post-metadata">

**Author:** ![Mark\_Soules](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_soules/32/42468_2.png) [@Mark\_Soules](https://discuss.elastic.co/u/Mark_Soules)\
**Post date:** [March 21, 2019, 12:31pm UTC](https://discuss.elastic.co/t/call-external-rest-api-from-kibana-plugin-server-side/173221/3 "2019-03-21T12:31:17Z")

</div>

There is no error message. The plugin doesn't get recognized at all and kibana continues normally. I use sh ./bin/kibana --dev and without the api call it builds normally and lists my plugin, but when I put in the external api call it doesn't build at all.

---

<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:** [April 18, 2019, 12:34pm UTC](https://discuss.elastic.co/t/call-external-rest-api-from-kibana-plugin-server-side/173221/4 "2019-04-18T12:34:59Z")

</div>

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