Create ticket using Queue Number instead of Queue Name

Good Day

I am currently creating tickets via Python using the queue name. However, I would like to make the script resilient against the queue renames. Is there a way to create tickets using a queue number instead of a queue name?

My python:

try:
        # ticket generator
        for i in range(0,len(tickets)):
                # generate content for ticket
                if tickets[i]['ticket_id'] == "create_ticket":
                    content = ("id: ticket/new" + '\n' +
                            "Queue: " + tickets[i]['queue'] + '\n' +
                            "Subject: " + tickets[i]['subject'] + '\n' +
                            "CF-Domain: " + tickets[i]['domain'] + '\n' +
                            "CF-Service Elements: " + tickets[i]['service_elements'] + '\n' +
                            "CF-Severity: " + tickets[i]['severity'] + '\n' +
                            "CF-Site: " + tickets[i]['site'] + '\n' +
                            "CF-Affected User: " + tickets[i]['affected_user'] + '\n' +
                            "CF-Workstation Name: " + tickets[i]['workstation_name'] + '\n' +
                            "CF-Recommendation: " + tickets[i]['recommendations'] + '\n' +
                            "CF-Source IP: " + tickets[i]['source_ip'] + '\n' +
                            "CF-Source Port: " + tickets[i]['source_port'] + '\n' +
                            "CF-Destination IP: " + tickets[i]['destination_ip'] + '\n' +
                            "CF-Destination Port: " + tickets[i]['destination_port'] + '\n' +
                            "CF-Additional Info: " + tickets[i]['additional_info'] + '\n' +
                            "CF-DetectedTime: " + tickets[i]['detectedtime'] + '\n' +
                            "CF-External Hostname: " + tickets[i]['external_hostname'] + '\n' +
                            "CF-Event ID: " + tickets[i]['event_id'] + '\n' +
                            "CF-File Name: " + tickets[i]['file_name'] + '\n' +
                            "CF-File Path: " + tickets[i]['file_path'] + '\n' +
                            "CF-Hash: " + tickets[i]['hash'] + '\n' +
                            "CF-Protocol: " + tickets[i]['protocol'] + '\n' +
                            "CF-Threat name: " + tickets[i]['threat_name'] + '\n' +
                            "CF-Ticket Reference: " + tickets[i]['ticket_reference'] + '\n' +
                            "CF-URL: " + tickets[i]['url'] + '\n' +
                            "CF-URL Category: " + tickets[i]['url_category'] + '\n' +
                            "CF-User Agent: " + tickets[i]['user_agent'] + '\n' +
                            "CF-Actual Error: " + tickets[i]['actual_error'] + '\n' +
                            "CF-Source Type: " + tickets[i]['source_type'] + '\n' +
                            "CC: " + tickets[i]['cc'])

                    # create a payload
                    payload = {'content': content}
                    # post 
                    r = requests.post(query, verify=False, params=payload)
                    # log the status after post
                    logger.info(r.content.replace('\n',' '))
except Exception as e:
                logger.error(str(e))                             

Thanks
Dhyata

Did you try using the queue id?

How would I use queue id?

Would it be:
"Queue ID: " + tickets[i][‘queue id’] + ‘\n’ +

Thank you for your assistance.

I don’t know what that tickets Python variable is so I cannot say, once you have the ID you should be able to use it instead of the name

Please forgive me, I am not fully understanding.

tickets python variable would usual be a queue name, so I am changing that to a number.

I don’t know how to use QueueID in a python context.

Please could you indicate.

 content = ("id: ticket/new" + '\n' +
                            "Queue: " + tickets[i]['queue'] + '\n' +
                            "Subject: " + tickets[i]['subject'] + '\n' +
                            "CF-Domain: " + tickets[i]['domain'] + '\n' +

Kind Regards
Dhyata

Isn’t tickets[i] a Python array that you are creating somewhere else in the code? I can’t tell you how to get the queue ID because I have no way of knowing what that tickets array contains since it doesn’t appear to be from RT but from some other source