I have CSV’s sent to me on a daily basis which need to be added to a table in my app. I’m having them automatically sent to a folder on my drive which will trigger a doPost script I’m working on. I have the spreadsheet importing and converting to JSON, however, I can’t figure out how to pass all of the rows of my spreadsheet into the POST request.
function doPost() {
var apiurl = ‘https://api.appsheet.com/api/v2/apps/MYAPPID/tables/MYTABLE/Action’;
var result = {};
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(‘THE SHEET I WANT TO IMPORT’)
.getDataRange()
.getValues();
result.sheet = makeObject(sheet);
Logger.log(result.sheet);
var body = {
“Action”: “Add”,
“Properties”: {
“Locale”: “en-US”,
“Location”: “47.623098, -122.330184”,
“Timezone”: “Eastern Standard Time”,
“RunAsUserEmail”: “myemail@ICANTCODEFORSHIT.com”
},
“Rows”: [{
“MY COLUMN NAME 1”: HOW DO I REFERENCE COLUMN 1 OF MY SHEET?,
“MY COLUMN NAME 2”: WTF DO I PUT HERE? WHY CAN I NOT FIGURE THIS OUT?
}
]
}}
var options = {
‘headers’ : {‘ApplicationAccessKey’ : ‘MYAPPLICATIONACCESSKEY’,
‘Accept’ : ‘application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8’,
‘Authorization’: ‘’
},
'method' : 'POST',
'muteHttpExceptions': true,
'contentType': 'application/json',
'payload': JSON.stringify(body),
};
console.log(JSON.stringify(options));
var response = UrlFetchApp.fetch(apiurl, options);
}
User | Count |
---|---|
17 | |
16 | |
4 | |
3 | |
2 |