diff --git a/server/controllers/wazuh-api-elastic.js b/server/controllers/wazuh-api-elastic.js index 78e744ab84..d35d90410e 100644 --- a/server/controllers/wazuh-api-elastic.js +++ b/server/controllers/wazuh-api-elastic.js @@ -164,7 +164,7 @@ export default class WazuhApiElastic { const settings = this.buildSettingsObject(req.payload); - await this.wzWrapper.updateWazuhIndexDocument(req.payload.id, { doc: settings }); + await this.wzWrapper.updateWazuhIndexDocument(req, { doc: settings }); return reply({ statusCode: 200, message: 'ok' }); diff --git a/server/lib/elastic-wrapper.js b/server/lib/elastic-wrapper.js index 0822dcb906..67c9503682 100644 --- a/server/lib/elastic-wrapper.js +++ b/server/lib/elastic-wrapper.js @@ -468,11 +468,12 @@ export default class ElasticWrapper { * @param {*} id * @param {*} doc */ - async updateWazuhIndexDocument(id,doc){ + async updateWazuhIndexDocument(req,doc){ try { - if(!id || !doc) return Promise.reject(new Error('No valid parameters given')) + const id = typeof req === 'object' && req.payload ? req.payload.id : req; + if(!id || !doc) throw new Error('No valid parameters given') - const data = await this.elasticRequest.callWithInternalUser('update', { + const data = await this.elasticRequest.callWithRequest(req, 'update', { index: '.wazuh', type : 'wazuh-configuration', id : id,