03 Jun 2024
08:52 AM
- last edited on
04 Jun 2024
07:01 AM
by
MaciejNeumann
Hi All,
We are trying to execute the below as a Workflow JavaScript but when we run it we are getting the error
Error: EdgeConnect request failed due to unexpected response from EdgeConnect dispatcher (status code: 400 Bad Request, error reason: {"error":{"code":400,"message":"Unexpected data!"}}).
at async Promise.all (index 0)
at async node:http:406:26
The IP / Hostname are in the host patterns are configured.
When running the same code from the EdgeConnect server it returns successfully,
Below is the code.
const https = require('https');
const options = {
hostname: 'host',
port: 1234,
path: '/xxxx/_xxxx',
method: 'GET',
auth: 'username:password',
rejectUnauthorized: false // This will ignore SSL certificate errors
};
const req = https.request(options, (res) => {
console.log(`statusCode: ${res.statusCode}`);
let data = '';
res.on('data', (d) => {
data += d;
});
res.on('end', () => {
try {
const parsedData = JSON.parse(data);
const cleanedData = parsedData.hits.hits.map(hit => hit._source);
// Output the cleaned data to the console
console.log(cleanedData);
} catch (err) {
console.error('Error processing data:', err);
}
});
});
req.on('error', (error) => {
console.error(error);
});
req.end();