Google Apps Script - Post Error - Unauthorized Access

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);
}

}

I’ve resolved my issue. In case anyone comes looking later, the below is now working.

function sendMeasurementToInfluxDB() {
const url = “http://chostname:8086/api/v2/write?org=ORG01&bucket=Buck01&precision=ns”;

try {
response = UrlFetchApp.fetch(url, {
method: ‘POST’,
headers: {
‘Authorization’: ‘Token 1234’,
‘Content-Type’: ‘text/plain; charset=utf-8’,
‘Accept’: ‘application/json’
},
payload: "measurement,key=XXX field=XXX "
})}
catch(error) {
Logger.log(‘Error sending data to InfluxDB:’, error);
};
}

@Jed_Hickman
Thanks for sharing your solution with the community!