Hi Alejandro,
Hope you are doing well.
Thanks for the clarification.
Actually, I have another Backend server. So the flow of api call/data is from PLUGIN UI -> PLUGIN SERVER -> BACKEND SERVER -> DB and vice versa.
So for some get requests, I need to pass a body from UI to server, and that's the reason I asked for the clarification. As you said, Body is not accepted from PLUGIN UI -> PLUGIN SEFVER GET request, but from PLUGIN SERVER -> Backend, I am able to pass body with GET request.
Now that I know by default, Kibana doesn't allow body with GET requests from plugin ui to server; I was thinking of the below flow.
PLUGIN UI -> PLUGIN SRRVER (all requests will be a POST request, within the body, I will pass method (which can be get, post, put, delete, ...) and the data .
{
method: 'GET',
data: {...}
}
So in PLUGIN SERVER, all routes will be post, within which it will check the method attribute passed within the body, and then accordingly makes that request to Backend server.
Eg: We want to GET the list of book, returning only the fields id and name.
PLUGIN UI -> PLUGIN SERVER
const body = {
method: 'GET',
data: {
fields: ['id', 'name']
}
};
axios.post(url, body);
PLUGIN SERVER -> BACKEND SERVER
router.post(
{
path: .....,
validate: {
body: {
method: schema.string(),
data: schema.maybe(schema.any())
}
}
}
),
async(context, request, response) => {
const backend_url = '.....';
const resp = await axios({
method: request.body.method,
backend_url,
data: request.body.data
}
.......
}
Is this way of api calling fine?
Thanks