Call External REST API from Kibana Plugin - Server side

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? as well as How to call external web service from Kibana Plugin?

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:

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);
});

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

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.

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