Using REST to create ticket//Error # Could not create ticket. Can't use an undefined value as an ARRAY reference

When I try to post data to RT using REST to create a new ticket, I receive these error message:

Can’t use an undefined value as an ARRAY reference at /usr/share/request-tracker3.8/html/REST/1.0/dhandler line 189. Stack: [/usr/share/request-tracker3.8/html/REST/1.0/dhandler:189] [/usr/share/request-tracker3.8/html/REST/1.0/autohandler:54] [/usr/share/request-tracker3.8/lib/RT/Interface/Web.pm:353] [/usr/share/request-tracker3.8/lib/RT/Interface/Web.pm:226] [/usr/share/request-tracker3.8/html/autohandler:53] 1

Here is my code in PHP

$arrfield = array(“id”=>“ticket/new”, “Requestor”=>"***", “Subject”=>“Test”, “Status”=>“new”, “Priority”=>“0”,“InitialPriority”=>“0”,“Starts”=>“2012-01-19 15:51:30”,“Text”=>“This is a test”,“Queue”=>“360_Link”);

$url = ‘http://cutest.wrlc.org/rt/REST/1.0/ticket/new’;
$fields = array( ‘user’=>’***’,
‘pass’=>’***’,
‘content’=>json_encode($arrfield)
);

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields);
$result = curl_exec($ch);
echo $result;
curl_close($ch);

Thanks
Kun

Hi,

The easiest way to learn what to send to REST interface is to use rt
command line utility and see what it sends.On Fri, Jan 20, 2012 at 01:39, Lin, Kun LINA@cua.edu wrote:

When I try to post data to RT using REST to create a new ticket, I receive
these error message:

Can’t use an undefined value as an ARRAY reference at
/usr/share/request-tracker3.8/html/REST/1.0/dhandler line 189. Stack:
[/usr/share/request-tracker3.8/html/REST/1.0/dhandler:189]
[/usr/share/request-tracker3.8/html/REST/1.0/autohandler:54]
[/usr/share/request-tracker3.8/lib/RT/Interface/Web.pm:353]
[/usr/share/request-tracker3.8/lib/RT/Interface/Web.pm:226]
[/usr/share/request-tracker3.8/html/autohandler:53] 1

Here is my code in PHP

$arrfield = array(“id”=>“ticket/new”, “Requestor”=>”***", “Subject”=>“Test”,
“Status”=>“new”,
“Priority”=>“0”,“InitialPriority”=>“0”,“Starts”=>“2012-01-19
15:51:30”,“Text”=>“This is a test”,“Queue”=>“360_Link”);

$url = ‘http://cutest.wrlc.org/rt/REST/1.0/ticket/new’;

$fields = array( ‘user’=>’***’,

                                            'pass'=>'***’,

‘content’=>json_encode($arrfield)

            );

$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,$url);

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch,CURLOPT_POSTFIELDS,$fields);

$result = curl_exec($ch);

echo $result;

curl_close($ch);

Thanks

Kun


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

  • Boston — March 5 & 6, 2012

List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel

Best regards, Ruslan.