[rt-users] [Perl script for RT ticket creation]

Stuart Browne stuart.browne at ausregistry.com.au
Thu Mar 4 17:17:34 EST 2010


> From: badreddine meherzi
>
> I'm new on RT and I want to write a perl script that creates
> a ticket in RT, so how can I proceed, wich are the Perl modules
> that I have to install and is there an example of Perl script
> creating an RT ticket(that would helps me a lot).

This is parts scraped from what I use:

#!/usr/bin/perl -w
use strict;
use RT::Client::REST;
my $user = '';
my $pass = ''
my $url = '';
my $subject = '';
my $text_body = '';

my $_RT = RT::Client::REST->new(
        server  => $url,
        timeout => 30,
);
if (!$_RT->login(
        username        => $user,
        password        => $pass,
)) {
        die ("Couldn't perform the login process\n");
}

my $number = $_RT->create(
        type    => 'ticket',
        set     => {
                queue   => 'Incident Response',
                status  => 'new',
                owner   => 'nobody',
                requestor       => $user,
                subject => $subject,
        },
        text    => $text_body,
);

if ($number > 0) {
        print "Ticket $number created successfully\n";
}
exit(0);
1;


Stuart J. Browne
Senior Unix Administrator, Network Administrator
AusRegistry Pty Ltd
Level 8, 10 Queens Road
Melbourne. Victoria. Australia. 3004.
Ph:  +61 3 9866 3710
Fax: +61 3 9866 1970
Email: stuart.browne at ausregistry.com.au
Web: www.ausregistry.com.au

The information contained in this communication is intended for the named recipients only. It is subject to copyright and may contain legally privileged and confidential information and if you are not an intended recipient you must not use, copy, distribute or take any action in reliance on it. If you have received this communication in error, please delete all copies from your system and notify us immediately.



More information about the rt-users mailing list