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" }
]
}
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
idandstatusto the columns "A" and "B" of the header row. And, please set the values ofidandstatus.Sample script:
Please copy and paste the following script to the script editor of Google Spreadsheet. And please set the variables.
When the values are retrieved from the Spreadsheet,
JSON.stringify({ tickets })is as follows.Note:
userandpwdare invalid, an error occurs. At that time, please confirm your values again.References:
PUT /api/v2/tickets/update_many, the document saysAccepts an array of up to 100 ticket objects, or a comma-separated list of up to 100 ticket ids.. Please be careful about this.