Skip to main content
Adaptive Insights
Knowledge and Support - Adaptive Insights

Test Connection

Test Connection Step 1: Create an HTTPS request to send to the Google Drive API using the testConnection function.

function testConnection(context) {
// Step 1: Create a https request to send to API
var URL = 'https://drive.google.com/uc?export=d...FJrak1oUVlpQzg';
var method = 'GET';
var body = '';
var headers = null;

Test Connection Step 2: Construct and send an HTTPS request to get all of the tables.

// Step 2: Send request and receive response
var response = ai.https.request(URL, method, body, headers);

Test Connection Step 3: Interrogate the response to check if it succeeded and that HTTP communication was successful.

// Step 3: Interrogate response to see if it was successful. Return true or false depending on the result.
//In this case we are just checking the response code.
var responseCode = response.getHttpCode();
if (responseCode == 200) {
ai.log.logInfo('Test Connection Succeeded','Response code was 200')
return true;
}else{
ai.log.logInfo('Test Connection Failed','Response code was not 200')
return false;
}
}

  • Was this article helpful?