PERL OTRS API - Création de Ticket / Article - ajout de piece jointe

Post Reply
benjamin1234
OTRS newbie
Posts: 8
Joined: 19 Nov 2014, 17:06
OTRS Version?: 1.5.0
Real Name: Benjamin PAYET
Company: b

PERL OTRS API - Création de Ticket / Article - ajout de piece jointe

Post by benjamin1234 » 17 Nov 2015, 12:53

Bonjour ,

Je souhaiterai écrire un script utilisant l'API d'OTRS permettant d'automatiser l'envoi de mail avec en piéce jointe un PDF.
Selon mes premiers tests, la création du ticket ainsi que l'article fonctionne, par contre je ne parviens par à ajouter ma pièce jointe.

Pouvez-vous m'aider ? Merci.

Code: Select all

my $RPC = Core->new();
my $TicketNumber = $RPC->Dispatch($SOAP_User, $SOAP_Pass, 'TicketObject','TicketCreateNumber');
print "RPC: New Ticketnumber created: ".$TicketNumber."\n";
my $TicketId = $RPC->Dispatch($SOAP_User, $SOAP_Pass, 'TicketObject', 'TicketCreate',
       TN => $TicketNumber,
       Title => 'Test Ticket',
       QueueID => 8,                # or QueueID => 123,
       Lock => 'unlock',
       PriorityID => 2,         # or PriorityID => 2,
       State => 'open',                # or StateID => 5,
       CustomerUser => 'customer at example.com',
       OwnerID => 1, # new owner
       ResponsibleID => 1, # new responsible
       UserID => 1,
);

$myFile = "rapport.pdf";
$contenttype = "text/plain";     
$mydir= "/home/benjamin/";
$mydirFile = $mydir . $myFile;



print "RPC: New Ticket id is: $TicketId\n";
my $ArticleID =$RPC->Dispatch($SOAP_User, $SOAP_Pass, 'TicketObject', 'ArticleCreate',
		TicketID         => $TicketId,
		ArticleType     => 'email-external',                   # email-external|email-internal|phone|fax|...
		SenderType       => 'system',                           # agent|system|customer
		From             => 'root <root@localhost>',  # not required but useful
		To               => 'Some Customer A', # not required but useful
		Cc               => '', # not required but useful
		ReplyTo          => '', # not required
		Subject          => 'TEST Ticket 2',          # required
		Body             => "Test Body",                # required
		#MessageID        => '',     # not required but useful
		Charset     => 'iso-8859-15',
		HistoryType      => 'EmailCustomer',                     # EmailCustomer|Move|AddNote|PriorityUpdate|WebRequestCustomer|...
		HistoryComment   => 'Some free text!',
		UserID           => 1,
		NoAgentNotify    => 0,                                 # if you don't want to send agent notifications
		MimeType          => 'text/plain',
		Loop             => 0,                       # auto reject|auto follow up|auto follow up|auto remove
		Attachment       , array(
			array('Content' => $theData,'ContentType' => $contenttype,'Filename' => $myFile)
			),
	);

print "RPC: Article ID created: ".$ArticleID."\n";

vincent13
OTRS newbie
Posts: 43
Joined: 28 May 2013, 12:38
OTRS Version?: 3.2000
Company: cpr sncf

Re: PERL OTRS API - Création de Ticket / Article - ajout de piece jointe

Post by vincent13 » 20 Nov 2015, 16:24

Je pense que la piece jointe ne peux qu'être lié qu'a un article.

Donc logiquement tu dois creer le ticket et ensuite creer un article ou tu poura lié ta pj.
lab : otrs 5rc1 test : otrs 3.3.15 prod : cluster 3.3.15

Post Reply