I’m developing a custom connector for Looker Studio (formerly Google Data Studio) to fetch data from a REST API. I’ve successfully deployed the connector and can see the schema, but I’m encountering an error when trying to create metrics in Looker Studio.
Error Message:
When attempting to create a metric, I receive this generic error:
“There was an error caused by this connector.”
Detailed Error Response:
{"dataResponse":[{"dataSubset":[{"requestId":"95f0f810-4706142-20240730","jobRequestUrl":[]}],"errorStatus":{"code":14,"reason":55,"reasonStr":"APPS_SCRIPT_ERROR_EXECUTION_FAILED","uniqueErrorCode":"a807a35b","category":5,"errorCategoryStr":"DATASET_CONFIGURATION","errorDetails":{"appsScriptErrorDetails":{"connectorMessage":{"type":3,"userMessage":"There was an error caused by this connector."}}}}}]}
function getData(request) {
try {
var endpoint = request.configParams.apiEndpoint;
console.log('Fetching data from endpoint:', endpoint);
console.log('Requested fields:', JSON.stringify(request.fields));
var data = fetchData(endpoint);
console.log('Fetched data:', JSON.stringify(data).slice(0, 500) + '...');
var formattedData = formatData(data, request.fields);
console.log('Formatted data:', JSON.stringify(formattedData).slice(0, 500) + '...');
var result = { schema: request.fields, rows: formattedData };
console.log('Returning result:', JSON.stringify(result).slice(0, 500) + '...');
return result;
} catch (error) {
console.error('Error in getData:', error);
throwConnectorError('Detailed error in getData: ' + error.message);
}
}
function fetchData(endpoint) {
// ... implementation details ...
}
function formatData(data, requestedFields) {
// ... implementation details ...
}
function throwConnectorError(message) {
DataStudioApp.createCommunityConnector()
.newUserError()
.setDebugText(message)
.setText('There was an error in the connector. Please check the deployment logs for more details.')
.throwException();
}
Added detailed logging throughout the getData, fetchData, and formatData functions.
Implemented error handling with try-catch blocks.
Verified that the API endpoint is accessible and returning data as expected.
Double-checked that the schema defined in getSchema matches the structure of the API response.
Ensured all fields used in Looker Studio are present in the API response.
Questions:
How can I get more detailed error information from Looker Studio or Apps Script to diagnose this issue?
Are there any common pitfalls or gotchas when implementing custom connectors that might cause this type of error?
Is there a way to debug the connector in real-time as Looker Studio is querying it?
Any insights or suggestions on how to resolve this error would be greatly appreciated. Thank you!
Tags: google-data-studio looker-studio google-apps-script api rest custom-connector
Amit Jadhav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.