Hi!
I’ve activated the tick to “Allow cloud-based services like Data Studio and Zapier to communicate with your app” where I get the app-id and the access key.
I use them to create a Post Request as indicated by the steps explained in https://support.google.com/appsheet/answer/10105398?sjid=7708427411471078865-EU. This Post is creaed using Postman. I send the request to add two rows in a database table that is used by the App and I always get the response 200 Ok. But the row isn’t added.
here my script code :
function listFilesInFolder() {
var folderId = ‘…’; // Remplacez par l’ID de votre dossier Google Drive
var folder = DriveApp.getFolderById(folderId);
var files = folder.getFilesByType(MimeType.PDF); // Récupère tous les fichiers PDF du dossier
// Informations pour l’API AppSheet
var appId = ‘…’; // Remplacez par votre App ID
var tableName = ‘test’; // Remplacez par le nom de votre table dans AppSheet
var apiKey = ‘…’; // Remplacez par votre clé d’API AppSheet
// URL de l’API pour ajouter des données
var apiUrl = [https://appsheet.com/api/v2/apps/](https://appsheet.com/api/v2/apps/)${appId}/tables/${tableName}/add;
// Parcourt les fichiers et envoie chaque lien vers AppSheet
while (files.hasNext()) {
var file = files.next();
var fileName = file.getName();
var fileUrl = file.getUrl(); // URL du fichier PDF
var lastUpdated = file.getLastUpdated();
// Créer les données à envoyer à AppSheet
var payload = {
“Action”: “Add”,
“Properties”: {},
“Rows”: [
{
“title”: fileName, // Correspond au nom de la colonne dans votre table AppSheet
“url”: fileUrl, // Correspond à la colonne où vous voulez stocker le lien PDF
}
]
};
// Envoyer les données via l’API AppSheet
var options = {
‘method’: ‘post’,
‘contentType’: ‘application/json’,
‘headers’: {
‘ApplicationAccessKey’: apiKey
},
‘payload’: JSON.stringify(payload)
};
var response = UrlFetchApp.fetch(apiUrl, options);
var responseCode = response.getResponseCode();
if (responseCode === 200) {
Logger.log(Successfully added: ${fileName});
} else {
Logger.log(Error adding ${fileName}: ${response.getContentText()});
}
}
}
Is there a log that I can check to try to find more information about the problem?