skepticdev has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, monks!

I come to you in desperate need of some spiritual(technical) guidance. I've recently been handed the task of improving our customer support internal process by integrating our help desk (RT) with our project management tool (http://www.project-open.com/). Bear in mind that I just started getting familiarized with Perl, it's syntax, it's functionalities, and it's philosophy; I'm only a junior developer with scarce knowledge and that has only worked with ABAP language so far, regardless, my hunger for knowledge about your ways and it's good practices is big. These past few days I've been immersing myself deep into documentation and forums but, since time is a factor, I decided to turn to you for some guidance.

Now for the task at hand: the process should be simple for anyone familiar enough with Perl and consuming APIs (not my case unfortunately). Whenever a new ticket is submitted in our RT help desk, a script should automatically communicate with ProjectOpen's API (http://www.project-open.net/en/package-intranet-rest) passing some values like for example, name of our client's company, this should trigger the creation of a ticket in PO in said client's latest open project; and it should then return to RT with values such as: ID of the newly created ticket and the URL to the ticket itself so that I can use those values to update the help.desk with another script.

I think I won't need any help learning the Perl syntax in order to get any of the said necessary values, but I do need some help in understanding the process of communicating with another app's API, how to pass over the desired values, and how to properly retrieve the return values with a script. From what I learned in my research the modules RT::Client::REST, LWP::UserAgent and JSON might be of help here, but since the Perl syntax and functionalities are nowhere near to ABAP (what I usually work with) some code examples on how to use them to pass and retrieve values from APIs are probably what I need.

I submit myself to your wisdom, esteemed monks.

  • Comment on Perl Acolyte in need for some guidance regarding RT integration with project management app.

Replies are listed 'Best First'.
Re: Perl Acolyte in need for some guidance regarding RT integration with project management app.
by 1nickt (Canon) on Apr 21, 2020 at 17:35 UTC

    Hi, welcome to Perl, the One True Religion.

    RT::Client::REST looks good. Have you read the doc? Usually a decent Perl module on the CPAN will provide working code in the SYNOPSIS section. Another good place to look for samples is in the distribution's t/ test directory, where the author (should) exercise the code.

    And in the case of this module, there is an extensive collection of examples in the examples/ directory.

    From what I can see, you won't need to use LWP directly.

    ## https://metacpan.org/source/DJZORT/RT-Client-REST-0.56/examples/cre +ate_ticket.pl #!/usr/bin/perl # # create_ticket.pl -- create an RT ticket. use strict; use warnings; use RT::Client::REST; use RT::Client::REST::Ticket; unless (@ARGV >= 3) { die "Usage: $0 username password queue subject\n"; } my $rt = RT::Client::REST->new( server => ($ENV{RTSERVER} || 'http://rt.cpan.org'), ); $rt->login( username=> shift(@ARGV), password=> shift(@ARGV), ); print "Please enter the text of the ticket:\n"; my $text = join('', <STDIN>); my $ticket = RT::Client::REST::Ticket->new( rt => $rt, queue => shift(@ARGV), subject => shift(@ARGV), )->store(text => $text); use Data::Dumper; print Dumper($ticket);

    Hope this helps!


    The way forward always starts with a minimal test.

      I haven't seen the examples section of CPAN before, this was really useful. But, please correct me if I am wrong, what I get from that code example for "use RT::Client::REST::Ticket" is that it triggers the creation of a new RT ticket, whereas what I need to do is the opposite.

      Users will create tickets manually in our RT help desk, this event should trigger a script that connects to Project Open's API (http://www.project-open.net/en/package-intranet-rest) passing values from the RT ticket created by the user in order to trigger the creation of a corresponding ticket IN Project Open (Not a new RT Ticket). It should then return from Project Open with some information regarding this new PO ticket that I will use to update the status of the ticket created manually by the user in the first place

      To sum up what I need to understand is:

      1) How to use these modules to pass the desired values from RT to Project Open

      2) In the same script I passed these values I need to trigger Project Open's ticket creation method

      3) Return to RT with information about the new ticket created in Project Open which I will use in a new and simple script to update the status of our client's request

        Hi again, check out REST::Client which you can configure to connect to any Restful API, which Project Open appears to be.

        Update: Usually, REST APIs pass data back and forth serialized as JSON. Your script's request routine would serialize the data from the RT ticket to a JSON obj and pass that to Project Open in the body of the API request. The response content will likely also be a JSON object which the response processing routine in your script would deserialize and then use as Perl data.

        Hope this helps!


        The way forward always starts with a minimal test.
Re: Perl Acolyte in need for some guidance regarding RT integration with project management app.
by choroba (Cardinal) on Apr 22, 2020 at 09:22 UTC
    Crossposted to Reddit. It's considered polite to inform about crossposting to make it possible for people not attending both sites to check what's been said at the other end of the internet.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      Yeah, sorry about that. It wasn't a simultaneous crosspost though, when I posted in reddit I was just getting into the subject and had just gotten this assignment, whereas when I decided to ask for a more specific question here I had already done all my script work, understood basic Perl syntax, and was about to get into the more complex API integration part of it.

Re: Perl Acolyte in need for some guidance regarding RT integration with project management app.
by jcb (Parson) on Apr 22, 2020 at 01:40 UTC

    If you are completely new to Perl, you may also want to visit learn.perl.org.