Forum
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: '<html>\r\n' +
'<head><title>502 Bad Gateway</title></head>\r\n' +
'<body bgcolor="white">\r\n' +
'<center><h1>502 Bad Gateway</h1></center>\r\n' +
'<hr><center>nginx/1.10.3</center>\r\n' +
'</body>\r\n' +
'</html>\r\n'
}
}
Posted by douglas mogoba 3 months ago
allowedAutoedit...
MyAutoedit...
Posted by Mr. Sarasin Klinklom about 4 years ago
GetHousePrice
Hello,
Is it possible to have the API "Get House Price" for houseCostCalculatorV2 to be fixed? (because I am using it for one of my school project) All the response for request of that API returns error. Sorry for the trouble. Thanks!
Posted by YongWei over 4 years ago
Accumulation Calculator
I tried to input the send request as
var data = JSON.stringify({
"yearsToGoal": "10",
"compound": "12",
"confidence": "0.95",
"discreteExpectedVolatility": "0.1103",
"discreteExpectedReturnPerAnnum": "0.0514",
"initialInvestment": "0",
"annualInvestment": "1000",
"currentYear": "2018",
"period": "beg"
});
Tried both with or without the "period"
Both return this error response.
{"response":{"discreteExpectedVolatility":["can't be blank"],"discreteExpectedReturnPerAnnum":["can't be blank"],"yearsToGoal":["can't be blank"],"initialInvestment":["can't be blank"],"annualInvestment":["can't be blank"],"currentYear":["can't be blank"]}}
But the values worked well when it is used on the website API UI.
Posted by YongWei about 5 years ago
Get House Price
The web interface is not functional as it does not parse the inputs into JSON object. And secondly, the web interface does not take into consideration for null inputs.
And even after I parse my object into JSON object, for instance, {'country':'Singapore', 'regionInput':null, 'cityInput':null, 'locationInput':'Ang Mo Kio', 'districtInput':'20', 'houseTypeInput':'HDB', 'roomTypeInput':'Executive'}, which is one of the returned valid datapoint. It returns me a bad request of {"error":{"statusCode":400,"name":"Error","message":"country is a required argument"}}
Thirdly, if the fields are stated required, does that mean other fields in the api request itself are optional? And if so, does that mean if I input in country as Singapore and location as Ang Mo Kio, will it return all the datapoints that satisfy both conditions?
Lastly, it would be nice if you save the text input of the user in the "Ask a Question" section, such that in the case that [Error: You need to fill out your name and email!], the user (me) do not have to retype everything again.
Posted by YongWei about 5 years ago
Issue with "number of array" in the API library
Hi,
I'm unable to add the same value into an array.
Posted by Hong Xiang over 5 years ago
Risk Profile Methodology
What's the Risk Profile Methodology. If my bank has their own model, are we able to amend your logic?
Posted by Joshua over 5 years ago
University Calculator
Can you explain how does the University Calculator work?
Posted by Jane over 5 years ago
How do i get started
HI, i would like to know more!
Posted by paul over 5 years ago