I developed a plugin in which it calls Rest APIs well by adding access_token in the ajax url. ( ex. 'https://api.zenginehq.com/v1/forms/' + value.id + '/records?limit=100' + access_token; )
I got the access_token in the https://platform.zenginehq.com/account/developer page but it will expired within 1 hour.
I need to know how to set my api url in which I don't need to update my access token every hour by myself, since this plugin is going to publish to be used for few people.
I removed the access_token, after i read <https://groups.google.com/g/zengine-development/c/O7EB-drRiX8> posted by Wes on Oct 18, 2023, 2:09:45 PM. It mentioned 'while approach two will run on our servers and will automatically get an access token.' Unfortunately , I got the result '400 Bad Request'. So I think I still need to have access token.
May I know how to call rest API in a plugin in which I don't have to update the access token every hour and allow other people use it?
Thank you very much.
Allen
let myUrl = 'https://api.zenginehq.com/v1/forms/' + value.id + '/records/count';
znPluginData({
namespace: context.plugin.namespace,
method: 'get',
route: myUrl
//options: {
// params: {
// //id: context.workspace.forms[0].id
// }
//}
}).then((result) => {
if (result.totalCount > 0) {
let totalRecordsInThisForm = result.totalCount == undefined ? 0 : result.totalCount;
/*let paginate = 1;*/
let maxRowsZenginApiLoaded = 100;
let totalPages = (totalRecordsInThisForm % maxRowsZenginApiLoaded == 0) ? Math.floor(totalRecordsInThisForm / maxRowsZenginApiLoaded) : Math.floor(totalRecordsInThisForm / maxRowsZenginApiLoaded) + 1;
}
}).catch(() => {
znMessage('Backend Service Fail', 'error');
});