Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I check the results of an issue generated by the JIRA :: REST Module in a Perl environment?

alex seol February 11, 2019

Hi, Team.

I created an issue using the JIRA :: REST module in the perl environment as shown below.

------------------------------------------------
use utf8;
use Filehandle;
use strict;
use warnings;
use Encode;
use JIRA::REST;

my $jira = JIRA::REST -> new({
url => 'http://company.domain:8080',
username => 'xxxxx',
password => 'xxxxxxxxxx',
});
# print FILE_H "jira: ".$jira." \n\n" ;
my $issue = $jira -> POST('/issue', undef, {
fields => {
project => {key => 'SMPKB'},
issuetype => {name => 'Task'},
summary => 'JIRA-REST, summary.',
description => 'bla bla bla.',
},
});
------------------------------------------------

I also checked the issue created by logging into Atlassian Jira.

How do I check the return value of an issue generated without logging into Atlassian Jira?

I need to be able to check in a Perl environment.

Alex

 

1 answer

1 accepted

0 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 14, 2019

While I'm not an expert in using Perl, since you're using the REST API here, I can say that anytime you create an issue using the POST /rest/api/2/issue endpoint, Jira will provide you a response when that issue is created.   It will look something like this:

{
  "id": "10261",
  "key": "SCRUM-27",
  "self": "http://localhost:8080/rest/api/2/issue/10261"
}

There is a json payload response that Jira will issue for each POST request to that endpoint.   If you make a bad request, then there tends to be an error message there instead.

It occurs to me now that perhaps you are not seeing this json response when using Perl to make REST calls.  If that is the case, check out this guide Fisheye/Crucible Developers: Writing a REST Client in Perl.  It suggests the use of Data::Dumper in order make sure your Perl can capture the json response of the REST server.

 

With this json response information, we now know the issue key for this particular issue is 'SCRUM-27' and the internal id number of that issue '10261'.   You can then use either of these values to query that issue via REST again.   In this case you could use the endpoint GET /rest/api/2/issue/SCRUM-27 in order to get back from Jira the fields on that issue and their values.

I hope this helps.

Andy

alex seol February 18, 2019

Hi, Nic
I got it.
I changed the source as shown below and got the desired result.

use utf8;
use Filehandle;
use strict;
use warnings;
use Encode;
use JIRA::REST;
use Data::Dumper;

my $jira = JIRA::REST -> new({
url => 'http://company.domain:8080',
username => 'xxxxxx',
password => 'xxxxxx',
});

my $issue = $jira -> POST('/issue', undef, {
fields => {
project => {key => 'SMPKB'},
issuetype => {name => 'Task'},
summary => 'Check Return Values.',
description => 'Return Value: id, key.',
},
});

print Dumper($issue);

my $fields = $issue->{fields};
my $id = $issue->{id};
print "id = $id\n";

 

Thanks to iragudo and Nic for their help.

Thank you very much.

Cheers,
Alex

Suggest an answer

Log in or Sign up to answer