[rt-users] Create RT ticket via perl, within RT but not via web interface?

Thomas Sibley trs at bestpractical.com
Mon Dec 3 17:12:57 EST 2012


On 12/03/2012 01:43 PM, Len Jaffe wrote:
> I have a data collection app that needs to finish by created a ticket.
> The app itself is protected by RT's authentication (user and password),
> and the app uses RT's mason environment.
> 
> RT::Client::REST is demanding a login. I don't have the user's
> credentials, so I figure I need to find the RT session cookie and pass that.
> 
> What's the proper way to pull the session cookie out of $m or $r, and is
> this the best way to get the new ticket created?

Since you're using RT's Mason handling, you should use the Perl API
directly instead of using the REST API via RT::Client::REST.  Using REST
would be an added level of indirection and complexity in that scenario.

You want to look at the CreateTicket() function provided to Mason
components by RT::Interface::Web and how it's used elsewhere.  In a
nutshell, it constructs an RT::Ticket object using $session{CurrentUser}
(an RT::CurrentUser object) as the current user and then calls ->Create.

Use perldoc to read the Perl API doc, or browse our doc site:
http://bestpractical.com/rt/docs/4.0/

Some parts of the doc are much better than others, but as a baseline
it's a good start.



More information about the rt-users mailing list