Google Cloud Functions - update data tables

Hello All,

It's my first post and I'm not a programmer.
I need to update a Data Table with data from external system.
What I want to do is to gather all keys from data table, then search other system using those keys and finally update datatables with new data. And it works from my nodejs server. I have rewritten my script for Google Functions but it does not update my datatable. I'm able to get all key values, but something is goes wrong when updating.

For troubleshooting I've created limited script that has key values hardcoded and updates data table with fixed data. And it's still not working as it should. Some of rows are updated though.
The interesting thing is that even if I receive failures for all rows I can see that some of them are updated.
For 30 rows I can get 30 failures but about 5-15 rows will be updated. Even if I get a number of success messages, the real number of updated rows is higher.
The failure message:
{"status":0,"statusText":"error","headers":[],"body":{},"text":"error","error":{"timeout":16000,"code":"ECONNABORTED","errno":"ETIME"}}

Anyone can tell me, what is the reason?

Regards,
Wojciech

PS. Below the code run on Google Functions:

exports.DataTableUpdater = (event, context) => { 
	const 	platformClient = require('purecloud-platform-client-v2');
	const	client = platformClient.ApiClient.instance;
	const	architectApi = new platformClient.ArchitectApi();
	const	clientId = process.env.GENESYS_CLOUD_CLIENT_ID;
	const	clientSecret = process.env.GENESYS_CLOUD_CLIENT_SECRET;
	const	dataTableId = process.env.GENESYS_CLOUD_DataTable_ID;
	const	keysArray = ['10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40']; 
	client.setEnvironment(platformClient.PureCloudRegionHosts.eu_central_1);
	client.loginClientCredentialsGrant(clientId, clientSecret)
	.then (token => {
		keysArray.forEach(keyValue => {
			getKeyValues(keyValue)
			.then( row => {
				architectApi.putFlowsDatatableRow(dataTableId, row["body"].key, row)
				.then( data => {
					console.log('Success calling putFlowsDatatableRow for key: ' + data.key);
				})
				.catch( err => {
					console.log('Failure calling putFlowsDatatableRow for key: ', row["body"].key, '\t', JSON.stringify(err));
				});  
			});
		});
	})
	.catch( err => {
		console.log('There was a failure');
		console.error(err);
	});

	function getKeyValues(id){
		return new Promise( function(resolve, reject) {
			let row={body:{key : id,DataA:'Test Name',DataB:"Test data",DataC:"Test data",DataD:"Test data",DataE:"Test data",DataF:"Test data",DataG:"Test data",DataH:"Test data"}};
			resolve(row);
		});	
	}	
}

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.