Google Apps脚本错误响应代码:413。消息:响应太大

时间:2017-06-10 11:46:51

标签: google-apps-script

我正在尝试使用此脚本从Google Apps管理面板导出MDM数据\ 该脚本只生成200个条目,然后抛出错误消息“响应代码:413。消息:响应太大”

请帮我解决问题

function loadMobileDevices(query) {
  var pageToken, page;
  var sheet = SpreadsheetApp.getActiveSpreadsheet();
  // First we remove the existing content from the active sheet
  sheet.getActiveSheet().clearContents();
  // Then we add the headers to the active sheet
  sheet.appendRow([
    'Resource Id',
    'Device Id',
    'Status',
    'Type',
    'Email',
    'First Sync',
    'Last Sync',
    'Hardware Id',
    'Model',
    'Name',
    'OS',
    'serialNumber',
    'Deviceimei',
    'supportsWorkProfile'
  ]);
  // Try to retrieve the mobile devices, show msg box containing the error if it fails 
  try {
    do {
      page = AdminDirectory.Mobiledevices.list('my_customer', {
        maxResults: 500,
        pageToken: pageToken,
        allowLargeResults: true,
        query: query

      });
      var devices = page.mobiledevices;
      if (devices) {
        //for (var i = 0; i < 1000; i++){
        for (var i = 0; i < devices.length; i++) {
          var device = devices[i];
          // You can customize the list of fields choosing from:
          // https://developers.google.com/admin-sdk/directory/v1/reference/mobiledevices
          // Remember to adjust the column header accordingly
          sheet.appendRow([
            device.resourceId,
            device.deviceId,
            device.status,
            device.type,
            device.email[0],
            device.hardwareId,
            device.firstSync,
            device.lastSync,
            device.model,
            device.name,
            device.os,
            device.serialNumber,
            device.imei,
            device.supportsWorkProfile
          ]);
        }
      }
      pageToken = page.nextPageToken;
    } while (pageToken);
  } catch(err) {
    Browser.msgBox(err.message);
  }

}

0 个答案:

没有答案