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

350
Vistas
Zendesk API: Update Multiple Tickets at once using PUT Method? How does it look like? Javascript/Google Script

I'm currently trying to do an API call to update multiple tickets at once using ticket IDs. These ticket IDs are stored on google Sheets since I have the script running there. I would appreciate someone sharing how to use the REST method and get it working! Thank you!

Problem: I'm not sure how to update multiple tickets using the following

If I try with 1 ticket ID, example PUT https://company.zendesk.com/api/v2/tickets/12345 This is from https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket. This will only update 1 ticket, fair.

Original Code: PUT /api/v2/tickets/{ticket_id} I know to just replace {ticket_id} with a ticket number. If I put something like https://company.zendesk.com/api/v2/tickets/{ticket_id} it will throw me an error.

When it comes to multiple: (Source: https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-many-tickets). How do I write the code in a way I can read multiple ticket ids at once without having to repeat it 10 time if there are 10 tickets?

PUT https://company.zendesk.com/api/v2/tickets/update_many

Zendesk's example is saying it like this:

{
  "tickets": [
    { "id": 1, "status": "solved" },
    { "id": 2, "status": "pending" }
  ]
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

When I saw your question, I thought that your goal might be able to be achieved by modifying this sample script. But, from your question, in your situation, I thought that when a sample modified script is shown, it might be useful for you and other users. So I posted a modified script instead of the duplicated question.

Prepare Spreadsheet:

This script retrieves the values from Spreadsheet. So, please set id and status to the columns "A" and "B" of the header row. And, please set the values of id and status.

Sample script:

Please copy and paste the following script to the script editor of Google Spreadsheet. And please set the variables.

function sample() {
  var url = 'https://{subdomain}.zendesk.com/api/v2/tickets/update_many.json'; // Please set your URL.
  var user = '###'; // Please set your user name.
  var pwd = '###'; // Please set your passworkd.
  var sheetName = "Sheet1"; // Please set the sheet name.

  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
  var [headers, ...rows] = sheet.getDataRange().getDisplayValues();
  var tickets = rows.map(r => {
    var temp = {};
    headers.forEach((h, j) => {
      if (r[j] != "") temp[h] = r[j];
    });
    return temp;
  });
  var options = {
    'method': 'PUT',
    'headers': { 'Authorization': "Basic " + Utilities.base64Encode(user + ':' + pwd) },
    'payload': JSON.stringify({ tickets }),
    'contentType': 'application/json',
    'muteHttpExceptions': true
  };
  var response = UrlFetchApp.fetch(url, options);
  console.log(response.getContentText());
}
  • When the values are retrieved from the Spreadsheet, JSON.stringify({ tickets }) is as follows.

      {
        "tickets": [
          {"id": "1", "status": "status1"},
          {"id": "2", "status": "status2"},
          {"id": "3", "status": "status3"},
          ,
          ,
          ,
        ]
      }
    

Note:

  • I think that if your values of user and pwd are invalid, an error occurs. At that time, please confirm your values again.

References:

  • Batch updates of Tickets
    • At PUT /api/v2/tickets/update_many, the document says Accepts an array of up to 100 ticket objects, or a comma-separated list of up to 100 ticket ids.. Please be careful about this.
  • Related thread.
    • Zendesk Update Users API From Google Sheets
  • fetch(url, params)
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