Check whether the API response is success using suitescript.

const SUCCESS_API_RESPONSES = {
    "OK": 200,
    "Created": 201,
    "Accepted": 202,
    "Non-Authoritative Information": 203,
    "No Content": 204,
    "Reset Content": 205,
    "Partial Content": 206,
    "Multi-Status (WebDAV)": 207,
    "Already Reported (WebDAV)": 208,
    "IM Used": 226
};
let response = https.post({
    url: `${endPoint}`,//
    body: `${JSON.stringify(payLoadJSON)}`,
    headers: headerObj//header details
});
if (Object.values(SUCCESS_API_RESPONSES).some(el => el === response.code)) {
    log.debug("API call is successful")
} else {
    log.debug("API call failed")
}


Leave a comment

Your email address will not be published. Required fields are marked *