Creating ticket with Attachment using Perl APIs (4.0.2)

I am trying to create a ticket with attachment thru the Perl APIs.

I don’t see a method in the RT::Ticket API for adding attachment during ticket creation.

When looking at the RT::Attachment API it says “This module should never be instantiated directly by client code. it’s an internal module which should only be instantiated through exported APIs”.

So wondering how I can create a ticket with attachment.

If any one have a few of lines of sample code that will be appreciated.

I am trying to create a ticket with attachment thru the Perl APIs.

I don’t see a method in the RT::Ticket API for adding attachment during
ticket creation.

When looking at the RT::Attachment API it says “This module should never
be instantiated directly by client code. it’s an internal module which
should only be instantiated through exported APIs”.

So wondering how I can create a ticket with attachment.

You need to construct a MIME entity and pass it in as the MIMEObj
argument. There is a not terribly simple example of this in
CreateTicket in RT::Interface::Web.

Thomas

Thanks Thomas…

Following lines of code did what I was looking for…

my $mimeObj = MIME::Entity->build(Description => “My Attachment”,
Path =>
“/path/to/file/file.pdf”,
Type => “application/pdf”,
Encoding => “base64”);

$mimeObj->attach(Path => “/path/to/file2/file2.pdf”,
Type => “application/pdf”,
Encoding => “base64”);

My @retValues = $ticket->Create( Queue => ‘My Queue’, Subject => 'Create
Ticket with PDF ', MIMEObj => $mimeObj);On 10/17/11 11:03 AM, “Thomas Sibley” trs@bestpractical.com wrote:

On 10/17/2011 01:47 PM, Srikumar Nair wrote:

I am trying to create a ticket with attachment thru the Perl APIs.

I don’t see a method in the RT::Ticket API for adding attachment during
ticket creation.

When looking at the RT::Attachment API it says “This module should never
be instantiated directly by client code. it’s an internal module which
should only be instantiated through exported APIs”.

So wondering how I can create a ticket with attachment.

You need to construct a MIME entity and pass it in as the MIMEObj
argument. There is a not terribly simple example of this in
CreateTicket in RT::Interface::Web.

Thomas

RT Training Sessions (http://bestpractical.com/services/training.html)

  • San Francisco, CA, USA October 18 & 19, 2011
  • Washington DC, USA October 31 & November 1, 2011
  • Barcelona, Spain November 28 & 29, 2011