Code for updating ticket data in bulk | XM Community
Skip to main content

Hello,
I have a requirement to update the ticket data in bulk for the tickets already created. I wanted to pass a new variable that is already passed in my surveyflow but not in the ticket, so I figured we can solve this using APIs. Can someone help me out with the Python or Javascript code for updating bulk records via APIs?

This would be extremely helpful so far the only way I know on how you can make this happen is by using the API url that qualtrics offers: 

https://api.qualtrics.com/65e3dd90f6e87-update-ticket-s-additional-data


@justin_j : 

Certainly, here’s a simplified Python script to update Qualtrics ticket data in bulk:

import requests

api_token = 'YOUR_API_TOKEN'
base_url = 'https://yourdatacenterid.qualtrics.com/API/v3/'
survey_id = 'YOUR_SURVEY_ID'
new_variable_value = 'NEW_VALUE'
ticket_ids = s'TICKET_ID_1', 'TICKET_ID_2', 'TICKET_ID_3']

for ticket_id in ticket_ids:
    update_data = {'new_variable_name': new_variable_value}
    response = requests.put(f'{base_url}surveys/{survey_id}/tickets/{ticket_id}', headers={'X-API-TOKEN': api_token}, json=update_data)
    if response.status_code == 200:
        print(f'Ticket {ticket_id} updated successfully.')
    else:
        print(f'Error updating ticket {ticket_id}. Status code: {response.status_code}')

Replace the placeholders with your specific information.


You will also have to import json library. I was able to build a similar code and it works when importing the library. 


 


Leave a Reply