Hi Eric,

I'm currently working in the same than you. I've tried to use rpc.pl but i cant make it work, so i tried the option of using a LWP::UserAgent connection making a post to the Action that i want to do and it works nice. To create a ticket you should post to AgentTicketPhone or CustomerTicketMessage (i used the last one because our other system should act as a "customer" of OTRS).

Hope that could be a good solution to your needs.

Greetings,
Eduardo Raffoul

2007/11/22, Partington, Eric <eric.partington@rbc.com >:

Hello Dev's, I have been trawling the lists and google to find a solution to my problem but have been unable to find anything to get me further than I am.

I found this script on the dev list from a while back and I have been trying to adapt it to work with OTRS 2.2.3 to create a ticket via perl.  The script is exactly where I need to start to help integrate the OTRS system into our workflow here. 

The script is shown below but the error message when I run it from /opt/otrs/bin/CreateTickets2-n.pl is:
[853232650@localhost bin]$ pwd
/opt/otrs/bin
[853232650@localhost bin]$ ./CreateTicket2-n.pl
Got no LogObject! at /opt/otrs/Kernel/System/Time.pm line 70, <PRODUCT> line 4.

-rwxrwxr-x  1 apache apache  2657 Nov 22 21:27 CreateTicket2-n.pl

I am sure the thing I am missing is very simple but I am at a loss as to where to proceed.  The CVS public API seems very straight forward but I cant get past the very basic point where I am.  Any pointers as to how to create a basic ticket with article from Perl using the API would be very appreciated.

Thanks for your help

#!/usr/bin/perl -w
# --
# create ticket with an article
# Copyright (C)
# --
# $Id: otrs.addUser,v 1.8 2003/03/06 22:11:59 martin Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --

use File::Basename;
use FindBin qw($RealBin);
use lib dirname($RealBin);
use lib dirname($RealBin)."/Kernel/cpan-lib";

use Kernel::Config;
use Kernel::System::Time;
use Kernel::System::Log;
use Kernel::System::DB;
use Kernel::System::Ticket;
my $ConfigObject = Kernel::Config->new();
my $TimeObject    = Kernel::System::Time->new(
    ConfigObject => $ConfigObject,
);
my $LogObject    = Kernel::System::Log->new(
    ConfigObject => $ConfigObject,
    LogPrefix => "CreateTicket.pl",
);
my $DBObject = Kernel::System::DB->new(
    ConfigObject => $ConfigObject,
    LogObject => $LogObject,
);
my $TicketObject = Kernel::System::Ticket->new(
    ConfigObject => $ConfigObject,
    LogObject => $LogObject,
    DBObject => $DBObject,
    TimeObject => $TimeObject,
);

my $TicketID = $TicketObject->TicketCreate(
    TN => $TicketObject->TicketCreateNumber(),
    Queue => 'Raw',
    Lock => 'unlock',
    GroupID => 1,
    Priority => '3 normal',
    State => 'new',
    CustomerNo => '',
    CustomerUser => '',
    UserID => 1, # current owner
    CreateUserID => 1,
);
print "Ticket (TicketID:$TicketID) created.\n";

if ($TicketID) {
    my $ArticleID = $TicketObject->ArticleCreate(
        TicketID => $TicketID,
        ArticleType => 'note-external', # email-external|email-internal|phone|fax|...
        SenderType => 'customer',         # agent|system|customer
        From => 'Some Agent <email@example.com>',   # not required but useful
        To => 'Some Customer A <customer-a@example.com>', # not required but useful
        Cc => 'Some Customer B <customer-b@example.com>', # not required but useful
        Subject => 'some short description',        # required
        Body => 'the message text',                 # required
        ContentType => 'text/plain; charset=ISO-8859-15',
        HistoryType => 'EmailCustomer',  # EmailCustomer|Move|AddNote|PriorityUpdate|WebRequestCustomer|...
        HistoryComment => 'Some free text!',
        UserID => 1,
    );
    print "Article (ArticleID:$ArticleID) aded to TicketID $TicketID.\n";
}

exit (0);

Security Monitoring and Compliance
Infrastructure Security Services
RBC Royal Bank of Canada

Tel: 416-348-4429

_______________________________________________________________________

This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.

Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite.
Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.

_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev