function uploadFeedData() {
const accountId = AdsUtilities.getCurrentAccountId();
const uploadType = 'UPDATE_ALL'; // UPDATE_ALL or UPDATE_PART
const SPREAD_SHEET_ID = '111112222233333AAAABBBBBCCCCC'; // The spreadsheet ID on Google Drive
const SPREAD_SHEET_NAME = 'sheetName'; // sheet name
// Obtain the feed ID (as it cannot be checked on the management screen)
let feedMaster = Display.FeedService.get({
accountId: accountId
}).rval;
if (feedMaster.totalNumEntries == 0) {
throw new Error('No feed ID exists in the account.');
}
const feedId = feedMaster.values[0].feed.feedId;
// Load the spreadsheet and format it as TSV
const sh = SpreadsheetApp.openById(SPREAD_SHEET_ID).getSheetByName(SPREAD_SHEET_NAME);
const dataArray = sh.getDataRange().getValues();
const fileContent = dataArray.map(row => row.join('\t')).join('\n');
// File upload
let uploadFeedData = Display.FeedDataService.upload(
accountId,
feedId,
uploadType,
false,
fileContent
).rval;
if (uploadFeedData.values[0].operationSucceeded) {
let feedData = uploadFeedData.values[0].feedData;
Logger.log('feedId -> ' + feedData.feedId
+ ', fileUploadStatus -> ' + feedData.fileUploadStatus
+ ', itemListUploadId -> ' + feedData.itemListUploadId + ' have been uploaded.');
} else {
Logger.log('feedId-> ' + feedId + ' could not to be uploaded.');
}
}