Back to All

502 bad gateway when calling https://sandbox-api.bambu.life/api/autoMl/v2/prediction

when calling the https://sandbox-api.bambu.life/api/autoMl/v2/prediction api i am getting 502 bad gateway error .
Here is my Express app code
const express = require("express");
const app = express();
const port = 3000;
const axios = require("axios");

const options = {
method: "POST",
url: "https://sandbox-api.bambu.life/api/autoMl/v2/prediction",
headers: {
accept: "application/json",
"content-type": "application/json",
authorization: "Bearer 765f3aa5fc2c32f6de324820",
},
data: {
clientId: "usa_prod",
model: "ensemble",
customer: [
{
nationality: "US",
gender: "male",
age: 28,
race: "US",
personalIncome: 8000,
savingsRatio: 0.75,
platformCountry: "US",
customerId: "0",
},
],
},
};

axios
.request(options)
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.error(error);
});

app.use(express.json());

app.get("/", (req, res) => {
res.send("Hello World!");
});

app.listen(port, () => {
console.log(Example app listening at http://localhost:${port});
});

and this is the output
Example app listening at http://localhost:3000
AxiosError: Request failed with status code 502
at settle (/Users/douglas/Documents/ifunza/express test app/node_modules/axios/dist/node/axios.cjs:1900:12)
at IncomingMessage.handleStreamEnd (/Users/douglas/Documents/ifunza/express test app/node_modules/axios/dist/node/axios.cjs:2952:11)
at IncomingMessage.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1358:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ERR_BAD_RESPONSE',
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [ 'xhr', 'http' ],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: { FormData: [Function], Blob: null },
validateStatus: [Function: validateStatus],
headers: AxiosHeaders {
Accept: 'application/json',
'Content-Type': 'application/json',
authorization: 'Bearer 765f3aa5fc2c32f6de324820',
'User-Agent': 'axios/1.3.4',
'Content-Length': '195',
'Accept-Encoding': 'gzip, compress, deflate, br'
},
method: 'post',
url: 'https://sandbox-api.bambu.life/api/autoMl/v2/prediction',
data: '{"clientId":"usa_prod","model":"ensemble","customer":[{"nationality":"US","gender":"male","age":28,"race":"US","personalIncome":8000,"savingsRatio":0.75,"platformCountry":"US","customerId":"0"}]}'
},
request: <ref 1> ClientRequest {
_events: [Object: null prototype] {
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
connect: [Function (anonymous)],
error: [Function (anonymous)],
socket: [Function (anonymous)],
timeout: [Function (anonymous)],
prefinish: [Function: requestOnPrefinish]
},
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
secureConnecting: false,
_SNICallback: null,
servername: 'sandbox-api.bambu.life',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 10,
connecting: false,
_hadError: false,
_parent: null,
_host: 'sandbox-api.bambu.life',
_readableState: [ReadableState],
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular
1],
[Symbol(res)]: [TLSWrap],
[Symbol(verified)]: true,
[Symbol(pendingSession)]: null,
[Symbol(async_id_symbol)]: 9,
[Symbol(kHandle)]: [TLSWrap],
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kSetNoDelay)]: false,
[Symbol(kSetKeepAlive)]: true,
[Symbol(kSetKeepAliveInitialDelay)]: 60,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(connect-options)]: [Object],
[Symbol(RequestTimeout)]: undefined
},
_header: 'POST /api/autoMl/v2/prediction HTTP/1.1\r\n' +
'Accept: application/json\r\n' +
'Content-Type: application/json\r\n' +
'authorization: Bearer 765f3aa5fc2c32f6de324820\r\n' +
'User-Agent: axios/1.3.4\r\n' +
'Content-Length: 195\r\n' +
'Accept-Encoding: gzip, compress, deflate, br\r\n' +
'Host: sandbox-api.bambu.life\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object: null prototype],
requests: [Object: null prototype] {},
sockets: [Object: null prototype],
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 1,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/api/autoMl/v2/prediction',
_ended: true,
res: IncomingMessage {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
socket: [TLSSocket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
rawHeaders: [Array],
rawTrailers: [],
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 502,
statusMessage: 'Bad Gateway',
client: [TLSSocket],
_consuming: false,
_dumped: false,
req: [Circular *1],
responseUrl: 'https://sandbox-api.bambu.life/api/autoMl/v2/prediction',
redirects: [],
[Symbol(kCapture)]: false,
[Symbol(kHeaders)]: [Object],
[Symbol(kHeadersCount)]: 30,
[Symbol(kTrailers)]: null,
[Symbol(kTrailersCount)]: 0,
[Symbol(RequestTimeout)]: undefined
},
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'sandbox-api.bambu.life',
protocol: 'https:',
_redirectable: Writable {
_writableState: [WritableState],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
_options: [Object],
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 195,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: [Circular *1],
_currentUrl: 'https://sandbox-api.bambu.life/api/autoMl/v2/prediction',
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [Array],
'content-type': [Array],
authorization: [Array],
'user-agent': [Array],
'content-length': [Array],
'accept-encoding': [Array],
host: [Array]
},
[Symbol(kUniqueHeaders)]: null
},
response: {
status: 502,
statusText: 'Bad Gateway',
headers: AxiosHeaders {
date: 'Wed, 22 Mar 2023 11:59:26 GMT',
'content-type': 'text/html',
'content-length': '173',
connection: 'close',
'access-control-allow-origin': '',
'x-xss-protection': '1; mode=block',
'x-frame-options': 'SAMEORIGIN',
'strict-transport-security': 'max-age=0; includeSubDomains',
'x-download-options': 'noopen',
'x-content-type-options': 'nosniff',
'x-ratelimit-limit': '5000',
'x-ratelimit-remaining': '4899',
server: 'nginx/1.10.3',
'set-cookie': [Array],
vary: 'Accept-Encoding'
},
config: {
transitional: [Object],
adapter: [Array],
transformRequest: [Array],
transformResponse: [Array],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: [Object],
validateStatus: [Function: validateStatus],
headers: [AxiosHeaders],
method: 'post',
url: 'https://sandbox-api.bambu.life/api/autoMl/v2/prediction',
data: '{"clientId":"usa_prod","model":"ensemble","customer":[{"nationality":"US","gender":"male","age":28,"race":"US","personalIncome":8000,"savingsRatio":0.75,"platformCountry":"US","customerId":"0"}]}'
},
request: <ref
1> ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: [TLSSocket],
_header: 'POST /api/autoMl/v2/prediction HTTP/1.1\r\n' +
'Accept: application/json\r\n' +
'Content-Type: application/json\r\n' +
'authorization: Bearer 765f3aa5fc2c32f6de324820\r\n' +
'User-Agent: axios/1.3.4\r\n' +
'Content-Length: 195\r\n' +
'Accept-Encoding: gzip, compress, deflate, br\r\n' +
'Host: sandbox-api.bambu.life\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: [Agent],
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/api/autoMl/v2/prediction',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'sandbox-api.bambu.life',
protocol: 'https:',
_redirectable: [Writable],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype],
[Symbol(kUniqueHeaders)]: null
},
data: '\r\n' +
'502 Bad Gateway\r\n' +
'\r\n' +
'

502 Bad Gateway

\r\n' +
'
nginx/1.10.3\r\n' +
'\r\n' +
'\r\n'
}
}