POST custom endpoint

hi team,
new in kibana and writiing custom endpoint for the POST requests for my plugin to update data from frontend.

my GET endpoint looks like this:

server.route({
    path: '/getmydata',
    method: 'GET',
    handler(req, reply) {
         return callWithRequest(req, 'search',{
 		'index':'myindex',
 		'q':'all'
 	});
  }
});

and how the POST endpoint should look like ? It should update my index from frontend.
P.S. timelion open code, unfortunately does not explain any sense for me.

Hey @masterThomas -

One example you might check out is the /fns endpoint in the core interpreter plugin.

In a nutshell:

  server.route({
    method: 'POST',
    path: `${API_ROUTE}/your_endpoint`,
    options: {
      payload: {
        allow: 'application/json',
        maxBytes: 26214400, // payload limit (25MB in this example)
      },
      validate: {
        payload: Joi.object({
           // your Joi validation config here
        }).required(),
      },
    },
    handler(req) {
      const { payload } = req;
      // do something with payload
    },
  });

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