7.9.2 http code convert ? to %3F. Rest API fails. Used to work

I'm trying to convert my plugin that works under 7.8.1 to 7.9.2. I use the saved object REST API.
In order to get all index patterns already created.
The REST API call look like:
'http://localhost:5601/api/saved_objects/_find?type=index-pattern"
I use the http instance that is passed into the plugin template unchanged.

Somehow the REST API gets converted internally to:
'http://localhost:5601/api/saved_objects/_find%3Ftype=index-pattern"
What i now get is a 404 Not Found error.

I've tried using curl with both command options. Version with ? works as expected.
Version with %3F fails in the same manner.
Is there an option that can be passed to the http get command that will stop it from converting ? -> %3F?
Is this a known bug in the latest release?

function used to do the call is shown below.

async function getRequest(type) {
console.log('getRequest:' + type);

const url = webSite + '/api/saved_objects/_find?type=' + type;
console.log('getRequest final url:' + url);

const response = await httpClient.get(url);
console.log('http get response:' + JSON.stringify(response));
return response;
}

What is the webSite variable? If it is the root URL of Kibana, such as https://localhost:5601, that could be the problem.

If this code is in a Kibana plugin, I think the idea should be to send a request to the URL path, not the full URL, since it is not a cross-domain request.

I checked the types in the 7.9 branch of the code to confirm this.

HttpSetup.get is a HttpHandler interface:

If HttpHandler is called with a string as the first argument and no second argument, it uses this definition: https://github.com/elastic/kibana/blob/7.9/src/core/public/http/types.ts#L278

Here, in the text of the code, we can see the string is given the identifier path which confirms my idea.

A faster way to confirm what kind of string should be passed to .get is to search for other usages of that method elsewhere in the code. I did a brief search and found the string is the path in existing code.

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