Hi all,

I am trying to access a ticket in an RT system with the intention of downloading the attachments for further processing and I am using v0.49 of the rt::client::rest API library.

Unfortunately I seem to have hit a bug in the code. Below is the relevant code piece:

... try { # Try and find some tickets @search = $rt->search(type => 'ticket', query => "id = '3188'" +); } catch RT::Client::REST::UnauthorizedActionException with { print STDERR "You are not authorized to execute this search.\n +"; } catch RT::Client::REST::Exception with { # something went wrong. die "Problem trying to execute a search: ", shift->message; }; exit 0 if (scalar(@search) < 1); foreach $id (@search) { # Retrieve each ticket from RT $ticket = $rt->show(type => 'ticket', id => $id); @attachment_ids = $rt->get_attachment_ids (id => $id); foreach(@attachment_ids) { print "Att_id: $_\n"; $att = $rt->get_attachment (parent_id => $id, id => $_ +); print Dumper($att); print "\n"; } }
Running the above causes the code to print out a few transactions that don't have file names and then crash with:
Use of uninitialized value in split at /usr/lib/perl5/site_perl/5.8.8/ +RT/Client/REST/Forms.pm line 38. Can't use an undefined value as an ARRAY reference at /usr/lib/perl5/s +ite_perl/5.8.8/RT/Client/REST.pm line 167.
The error is caused inside the call to get_attachment(). Does anyone have any example code that does retrieve file attachments or have an explanation to why I get the above error?

|\\/|artin


In reply to Accessing attachments using RT::Client::REST by wardmw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.