Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
Google Sheet, API results add to col 2

I’m trying to use a Google sheet with device Serial numbers in Col A and populate Col B with the device record ID held in our MDM using Google Apps Script and Jamf API.

I’ve got the script getting the ID based of the device Serial in the sheet but can’t figure out how to get it to populate in column B next to the serial number. At the moment it appends the rows below the serial list in Column B (screenshot attached)…feels like I’ve read a 100 websites now and not getting anywhere…any ideas?

function JamfHttpPutRequest() {

    var rows = SpreadsheetApp.openById("MYSHEETID").getSheetByName("Sheet1").getDataRange().getValues(),
      range,
      values_array; 
  
  rows.forEach(function(row, index){

  var serialnumber = rows[index][0];

    var url = "https://MYDOMAIN.jamfcloud.com/JSSResource/computers/serialnumber/" + serialnumber + "";
    var response = UrlFetchApp.fetch(url, {
        "method": "GET",
        "headers": {
            "Authorization": "Basic MYAUTH",
            "Content-Type": "application/xml"
        },
"muteHttpExceptions": true,
        "followRedirects": true,
        "validateHttpsCertificates": true,
        "contentType": "application/xml",

    }).getContentText();

  var document = XmlService.parse(response);
  var entries = document.getRootElement().getChild('general').getChild('id').getValue();

SpreadsheetApp.getActiveSheet().appendRow([null, (entries)]);

// Log items
  Logger.log(serialnumber);
  Logger.log(entries);

})
}

The above does this

Sheet, ID in col B low down

Trying to get it to do this which I copied and pasted in the correct place

Sheets ID next to serial

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Description

.appendRow() adds a new row after the least row containing data. What you want is getRange() instead as shown below.

Code.gs

function JamfHttpPutRequest() {

  var rows = SpreadsheetApp.openById("MYSHEETID").getSheetByName("Sheet1").getDataRange().getValues(),
      range,
      values_array; 
  
  var entries = [];

  rows.forEach(
    function(row, index){

      var serialnumber = row[0];

      var url = "https://MYDOMAIN.jamfcloud.com/JSSResource/computers/serialnumber/" + serialnumber + "";
      var response = UrlFetchApp.fetch(url, {
          "method": "GET",
          "headers": {
              "Authorization": "Basic MYAUTH",
              "Content-Type": "application/xml"
          },
          "muteHttpExceptions": true,
          "followRedirects": true,
          "validateHttpsCertificates": true,
          "contentType": "application/xml",

        }
      ).getContentText();

      var document = XmlService.parse(response);
      var entry = document.getRootElement().getChild('general').getChild('id').getValue();
      
      // assuming entry is a single value
      entries.push([entry])


      // Log items
      Logger.log(serialnumber);
      Logger.log(entries);

    }
  );

  // put values in row 1 column B
  SpreadsheetApp.getActiveSheet().getRange(1,2,entries.length,1).setValues(entries);

}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda