I’m trying to write data back to InfluxDB 2 from Google Apps Script (so Curl not available). Curl writes are successful using the same Token, so i’m assuming I have my code formatting off? Can anyone suggest changes/corrections?
Specific response : {“code”:“unauthorized”,“message”:“unauthorized access”}
Code below :
function writeInflux() {
var response;
var options = {
"method" : "post",
"muteHttpExceptions" : true,
"Authorization": "Token XXX",
"contentType": "text/plain; charset=utf-8",
"payload" : "XXX,system=XXX,app=XXX time=0222,date=03122025 "
};
try {
response = UrlFetchApp.fetch('http://XXX:8086/api/v2/write?org=XXX&bucket=XXX&precision=ns', options);
Logger.log(response.getContentText());
}
catch(err) {
Logger.log(err);
}
}