Called with an invalid endpoint: sql.query

I'm trying to develop a kibana plugin (Elasticsearch & Kibana both Ver 7.4.1). In order to get started i have used the known plugin analyse_api as an example and starting point.

I'm trying to invoke the Elasticsearch API of sql query. i.e. sql.query. This requires that i pass the required SQL string along with a know format string. My string is very simple: "SELECT ObsDate from websphere". Format is json.

At this point i'm getting the error "called with an invalid endpoint: sql.query" shown above and must admit i'm completely at a loss as to why!

To get things started , i call the sqlquery method to perform the post operation from the browser to the kibana server. Code segments are shown below.

import chrome from 'ui/chrome';
let httpClient;
export const setHttpClient = client => {
httpClient = client;

export const getHttpClient = () => {
return httpClient;

const apiPrefix = chrome.addBasePath('/api/analyze_api_ui');
export async function sqlquery(params) {
console.log('httpClient:' + httpClient);

console.log('sqlquery : Params:Query: ' + params.query + ' JSON:' + JSON.stringify(params));
console.log('sqlquery addBasepath:' + apiPrefix + ' params:' + params);
const response = await${apiPrefix}/sqlquery, params);
return response;

Eventually this gets routed to the following below:
let call = server.plugins.elasticsearch.getCluster('data').callWithRequest;

path: '/api/analyze_api_ui/sqlquery',
method: 'POST',
options: {
validate: {
payload: Joi.object()
query: Joi.string().required(),
handler: async req => {
let param = {
body: {
format: 'json',
query: req.payload.query,

  try {
    console.log('Sql.query params:' + JSON.stringify(param));
    const response = await call(req, 'sql.query', param);

      'Sql.query response details:' + JSON.stringify(response.detail),
      ' Request:' + param.body
    return {
      detail: response.detail,
      request: param.body,
  } catch (error) {
    console.log('Sql.query Error result:' + convertEsError(param.index, error));
    return convertEsError(param.index, error);

Error Trace:

In server route sqlquery:{"body":{"format":"json","query":"SELECT ObsDate FROM websphere"}}
Sql.query params:{"body":{"format":"json","query":"SELECT ObsDate FROM websphere"}}
callAPI:endpoint sql.query clientPath:sql,query api:undefined
Sql.query Error result:Error: called with an invalid endpoint: sql.query
server error [16:19:18.836] Error: called with an invalid endpoint: sql.query
at callAPI (/Users/pgervais/kibana/src/core/server/elasticsearch/cluster_client.ts:77:11)
at ScopedClusterClient.callAPI [as scopedAPICaller] (/Users/pgervais/kibana/src/core/server/elasticsearch/cluster_client.ts:222:18)
at ScopedClusterClient.scopedAPICaller (/Users/pgervais/kibana/src/core/server/elasticsearch/scoped_cluster_client.ts:93:17)
at callAsCurrentUser (/Users/pgervais/kibana/src/legacy/core_plugins/elasticsearch/lib/cluster.ts:37:8)
at call (/Users/pgervais/kibana/plugins/cbsa/server/routes/analyze.js:190:32)
at module.exports.internals.Manager.execute (/Users/pgervais/kibana/node_modules/hapi/lib/toolkit.js:35:106)
at Object.internals.handler (/Users/pgervais/kibana/node_modules/hapi/lib/handler.js:50:48)
at exports.execute (/Users/pgervais/kibana/node_modules/hapi/lib/handler.js:35:36)
at Request._lifecycle (/Users/pgervais/kibana/node_modules/hapi/lib/request.js:263:62)
at process._tickCallback (internal/process/next_tick.js:68:7)

I have tried a number of obvious changes:

  1. tried all permutations of params format all to no avail.
  2. Have added debug statements wherever i can.
  3. I have put console printouts in callAPI.

callAPI:endpoint sql.query clientPath:sql,query api:undefined
Note that the endpoint has sql.query whereas the clientPath has sql,query ? A comma separator. It's in callAPI where the error message is generated portions of the vcode shown below.

async function callAPI(
client: Client,
endpoint: string,
clientParams: Record<string, any> = {},
options: CallAPIOptions = { wrap401Errors: true }
): Promise {
const clientPath = endpoint.split('.');
const api: any = get(client, clientPath);
if (!api) {
console.log('callAPI:endpoint' + endpoint + ' clientPath:' + clientPath + ' api:' + api);
throw new Error(called with an invalid endpoint: ${endpoint});

Any help from kibana plugin gurus would be highly appreciated.

Could you try using