Hi monks,

I'm writing a class for accessing/modifying trac contents via XML::RPC.

It's working ok when I create or update tickets, wiki etc. I also can get/download attachments. No problem. The problem appears as soon as I try to add attachments to a ticket. It seems base64-encoding the data is not enough. The call to the specific remote procedure gives a "object has no 'data' attribute error":

use XML::RPC; use MIME::Base64; my $xmlrpc = XML::RPC->new('https://user:pass@some.server.com/trac/pro +ject/xmlrpc'); my $result = $xmlrpc->call('ticket.putAttachment', 2, 'Filename', 'Some Description', encode_base64('data, data - it is always th +e data') ); Dumpering $result gives: $VAR1 = { 'faultString' => '\'\'str\' object has no attribute \'data\' +\' while executing \'ticket.putAttachment()\'', 'faultCode' => '2' };
Unfortunately I do not quite understand the XML::RPC documentation and its talk about the CODEREF to create custom data types (which base64 and time seem to be). Has anyone an example of how to achieve feeding trac with binary data? Any help would be greatly appreciated.

Bye
 PetaMem
    All Perl:   MT, NLP, NLU


In reply to Accessing Trac via XML::RPC by PetaMem

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.