[rt-users] Creating a ticket with attachment in PHP

Guillaume Hilt ghilt at shadowprojects.org
Wed Apr 18 05:57:20 EDT 2012


     Hello,

I'm using RT 3.8.1 and REST API in PHP.

I'm creating a ticket this way :
$request        = new HttpRequest( $conf['rt']['url'] . 
'/REST/1.0/ticket/new?user=' . $conf['rt']['user'] . '&pass=' . 
$conf['rt']['password'], HTTP_METH_POST );
$rt_queue       = 
$conf['rt']['languages'][$conf['rt']['fallback_language']];
$post_data      = array( 'content' => "Queue: " . $rt_queue . 
"\nRequestor: " . $_SESSION['customer']['login'] . "\nCF-OS: " . 
$_POST['os'] . "\nSubject: " . $_POST['subject'] . "\nOwner: " . 
$_SESSION['customer']['login'] . "\nText: " . str_replace( "\n", "\n ", 
$_POST['message'] ) . "\n" );
$request->addPostFields( $post_data );
$request->send();

It works well.

Now i'm trying to add an attachment.

I tried to add "attachment_1: my file content" to my post data but it 
doesn't work.

What's the way to attach a file to a ticket using PHP ?

Regards,

-- 
   Guillaume Hilt




More information about the rt-users mailing list