Using API through Perl

Discussion and information for XML-RPC interface.

Moderators: Amaradana, TurboPT, TL Developers

Post Reply
releppes
TestLink user
Posts: 2
Joined: Mon Dec 21, 2009 1:48 pm
Location: Rochester, NY
Contact:

Using API through Perl

Post by releppes »

I just started using the XML-RCP API through Perl. There's no sample code, but here's the syntax I use.

Code: Select all

#!/usr/bin/perl

use XML::RPC;
use Data::Dumper;

my $xmlrpc = XML::RPC->new('http://.../lib/api/xmlrpc.php');

my $result = $xmlrpc->call('tl.reportTCResult', {
	devKey => '...',
	testcaseid => '...',
	testplanid => '...',
 	status => '...',
});

print(Dumper($result));
My question is about obtaining testplanid using the API. I can get testcaseid using the getTestCaseIDByName routine, but there's no such routine for testplanid.

I'm running TestLink 1.8.2.

For what's it's worth, I do have a means to obtain the testprojectid and testplanid using the following routines, but I wanted to know if there was an easier method:

Code: Select all

my $testprojects = $xmlrpc->call('tl.getProjects', {devKey => $devKey});
my $testprojectname = "Test";
my $testproject;

for (@$testprojects) {
	$testproject = $_ if $_->{name} eq $testprojectname;
}

print(Dumper({testproject=>$testproject}));

my $testplans = $xmlrpc->call('tl.getProjectTestPlans', {devKey => $devKey, testprojectid=>$testproject->{id}});
my $testplanname = "Regression";
my $testplan;

for (values(%{$testplans->[0]})) {
	$testplan = $_ if $_->{name} eq $testplanname;
}

print(Dumper({testplan=>$testplan}));

my $testprojectid = $testproject->{id};
my $testplanid = $testplan->{id};
austvik
Advanced user
Posts: 24
Joined: Thu Mar 25, 2010 7:25 am
Contact:

Post by austvik »

Hi,

I don't think there is any easier way, so I'll encourage you to create a feature request in the tracker. If you can specify what the new function should do and which parameters it should take, that would be great.

-J
Post Reply