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

**URL:** <https://discuss.elastic.co/t/callwithrequest-called-with-an-invalid-endpoint-client-search-error-in-kibana/55691>\
**Category:** Kibana\
**Created:** [July 17, 2016, 12:48pm UTC](https://discuss.elastic.co/t/callwithrequest-called-with-an-invalid-endpoint-client-search-error-in-kibana/55691 "2016-07-17T12:48:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krugar\_Kali](https://avatars.discourse-cdn.com/v4/letter/k/ee59a6/32.png) [@Krugar\_Kali](https://discuss.elastic.co/u/Krugar_Kali)\
**Post date:** [July 17, 2016, 12:48pm UTC](https://discuss.elastic.co/t/callwithrequest-called-with-an-invalid-endpoint-client-search-error-in-kibana/55691/1 "2016-07-17T12:48:17Z")

</div>

Hey guys,

I am trying to develop a visualization plugin for kibana. I was following [TIm Roes tutorial](https://www.timroes.de/2016/02/21/writing-kibana-plugins-custom-applications/#creating-a-new-server-api) and changed the code in the given link as follows :

```auto
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/,

```auto
$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)

```auto
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](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search) is a part of elasticsearch js.

Why am i getting this error?

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [July 18, 2016, 7:01pm UTC](https://discuss.elastic.co/t/callwithrequest-called-with-an-invalid-endpoint-client-search-error-in-kibana/55691/2 "2016-07-18T19:01:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Krugar\_Kali](https://avatars.discourse-cdn.com/v4/letter/k/ee59a6/32.png) [@Krugar\_Kali](https://discuss.elastic.co/u/Krugar_Kali)\
**Post date:** [July 18, 2016, 7:19pm UTC](https://discuss.elastic.co/t/callwithrequest-called-with-an-invalid-endpoint-client-search-error-in-kibana/55691/3 "2016-07-18T19:19:59Z")

</div>

Hi @shaunak,

My call implementation was this :

```auto
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

---

<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:** [July 6, 2017, 1:45pm UTC](https://discuss.elastic.co/t/callwithrequest-called-with-an-invalid-endpoint-client-search-error-in-kibana/55691/4 "2017-07-06T13:45:58Z")

</div>


