Hey folks,
Today we are facing a bit weird issue. We have a custom app that can be successfully installed. Iparams validation doesn’t work on the settings update page.
When we use the same request for API key validation. There is no error. it’s only return
json { message: "Something went wrong" }
My validation code:
/**
* Payload and other options can be specified using `options`
* Notice the presence of the debounce logic to avoid rate-limiting issues
*
* @param {string} value
*/
function validateAPIKey(value) {
if (value.trim().length === 0) {
return "Invalid API Key"
}
const url = "https://" + utils.get("freshdesk_subdomain") + ".myfreshworks.com/crm/sales/api/tasks";
const options = {
headers: {
'Content-Type': 'application/json',
'Authorization': `Token token=${utils.get("freshdesk_api_key")}`
}
};
const p = new Promise(function (resolve, reject) {
client.request.get(url, options).then(
function (_) {
resolve();
},
function (error) {
const { response } = error;
if (response === 'This domain has not been whitelisted') {
reject("Subdomain is invalid, please firstly check your subdomain.");
return
}
const { message } = JSON.parse(response);
if (message === 'Incorrect or expired API key') {
reject(message);
} else {
reject("API key or Subdomain is invalid.");
}
}
)
});
return p;
}
`