callWithRequest called with an invalid endpoint: client.search Error in kibana


(Krugar Kali) #1

Hey guys,

I am trying to develop a visualization plugin for kibana. I was following TIm Roes tutorial and changed the code in the given link as follows :

server.route({
   path: '/api/traffic_light_vis/search/{name}',
   method: 'GET',
   handler(req, reply) {
       call(req, 'search', {
           index: req.params.name,
           q:'*:*'
       }).then(function (response) {
             reply(response);
       });
    }
});

When I do $http query to ../api/traffic_light_vis/search/,

$http({
    method : "GET",
    url : '../api/traffic_light_vis/search/' + $scope.indices[i] //$scope.indices is array of indexes found
}).then(function mySuccess(response) {
        $scope.ini_data.push(response.data);
    }, function myError(response) {
    console.log(response);
    console.log(response.statustext);
    console.log(response.status);
    console.log(response.data);
});        

I get the following error from kibana(4.5.2)

Debug: internal, implementation, error 
    Error: Uncaught error: callWithRequest called with an invalid endpoint: client.search
    at /opt/kibana/src/plugins/elasticsearch/lib/call_with_request.js:22:21
    at handler (/opt/kibana/installedPlugins/traffic_light_vis/index.js:43:24)
    at Object.internals.handler (/opt/kibana/node_modules/hapi/lib/handler.js:93:36)
    at /opt/kibana/node_modules/hapi/lib/handler.js:28:23
    at [object Object].internals.Protect.run (/opt/kibana/node_modules/hapi/lib/protect.js:56:5)
    at exports.execute (/opt/kibana/node_modules/hapi/lib/handler.js:22:22)
    at /opt/kibana/node_modules/hapi/lib/request.js:370:13
    at iterate (/opt/kibana/node_modules/hapi/node_modules/items/lib/index.js:35:13)
    at done (/opt/kibana/node_modules/hapi/node_modules/items/lib/index.js:27:25)
    at /opt/kibana/node_modules/hapi/node_modules/hoek/lib/index.js:841:22
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickDomainCallback (node.js:390:13)

But client.search is a part of elasticsearch js.

Why am i getting this error?


(Shaunak Kashyap) #2

Hi @Krugar_Kali,

I think the issue here is that while you are passing in search to call, the corresponding argument being sent to callWithRequest is actually client.search. Can you share the implementation of the call function?

Thanks,

Shaunak


(Krugar Kali) #3

Hi @shaunak,

My call implementation was this :

let call = server.plugins.elasticsearch.callWithRequest;

But the issue is resolved. I was making a "GET" request instead of "POST". The error message just confused me a little bit. Thanks anyways.

Krugar


(system) #4