Adding an XML-RPC to append comments

Jeff Lasslett jeff.lasslett at datataker.com.au
Thu May 17 04:24:36 UTC 2007


Hello,

I've added the following subroutine to Bugzilla/WebServices/Bug.pm.
The goal is to be able to add comments to bugs using XML-RPC.

The routine is called as a web service.  The arguments seem to be
correct.  The trouble is that no comments are added.

My questions:-

        Can this 'add_comment' XMLRPC be made to work easily?  Am I
        close?  Or is there some reason why an 'add_comment' RPC is
	not possible at this time?

        Is there a 'trace' or 'log' for obtaining diagnostic/debugging
        messages from bugzilla while its running?  


sub add_comment
{
    my ($self, $params) = @_;

    my $user = Bugzilla->login(LOGIN_REQUIRED);

    return { success => type('string')->value('Bad user!') } if ( !
defined( $user ) );

    ValidateBugID($params->{bug});
    my $bug = new Bugzilla::Bug($params->{bug});

    return { success => type('string')->value('Bug not found!') } if ( !
defined( $user ) );

    my $uid = $user->id;
    my $bid = $bug->bug_id;

    Bugzilla::Bug->AppendComment( $bid, $uid, $params->{comment} );

#   Bugzilla::BugMail::Send($bug->bug_id, { changer =>
$bug->reporter->login });

    return { success => type('string')->value('You betcha!') };
}



Below is a fragment of perl that I am using to test it:-


$xmlrpc_result = $proxy->call('User.login', { login =>
'jeff.lasslett at datataker.com.au', password => 'password' } );
_die_on_fault($xmlrpc_result);

$xmlrpc_result = $proxy->call('Bug.create', { product     => "DT8x", 
                                              component   => "Firmware",
                                              summary     => "TestBug 12
- created from exodus.pl",
                                              version     => "6.18",
                                              description => "This is a
description of the bug... hohoho",
                                              op_sys      => "DT8x",
                                              platform    => "All",	
                                              priority    => "P4",
                                              severity    =>
"normal" } );
_die_on_fault($xmlrpc_result);

$result = $xmlrpc_result->result;

print "Added bug $$result{id}\n";

$xmlrpc_result = $proxy->call('Bug.add_comment', { bug => $$result{id},
comment => 'This is just a test bug comment!!' } );
_die_on_fault($xmlrpc_result);

$result = $xmlrpc_result->result;
#print( "uid:$$result{uid} bid:$$result{bid} msg:$$result{msg}\n" );
print "Did it work?? $$result{success}\n";








More information about the developers mailing list