Forums

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

I want to print only specific field values of a specific issue.

alex seol February 11, 2019

Hi, Team.

To get a specific issue for a particular Jira project, I wrote the following Perl script:

-----------------------------
use utf8;
use Filehandle;
use strict;

use warnings;
use Encode;

use JIRA::REST;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;

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

# Get issue.
my $issue = $jira -> GET("/issue/SMPKB-16");

my $json_text = do {
open(my $json_fh, "<:encoding(UTF-8)", $issue) or die ("Can't open \$issue\": $!\n");
local $/;
<$json_fh>
};

my $json = JSON -> new;
my $data = $json -> decode($json_text);

-----------------------------

However, I can not 'print' the summary and description fields of a particular issue.

I added a JSON script, but I still get an error (I use JSON for the first time).

I look forward to your help.

Alex.

2 answers

1 accepted

0 votes
Answer accepted
alex seol February 18, 2019

We solved it by following method.
my $jira = JIRA::REST -> new({
url => 'http://company.domain:8080',
username => 'xxxx',
password => 'xxxx',
});

my $issue = $jira -> GET("/issue/SMPKB-16?fields=summary,description");
my $fields = $issue->{fields};
print "summary = $fields->{summary}\n";
print "description = $fields->{description}\n";

The results below.
Active code page: 65001
F:\ideaic\perl\site\lib>perl ideaic_interface_jira_get.pl
summary = Issues like this one that are marked as fixed in a released version do not show up in Work mode but are included in the reports
Wide character in print at ideaic_interface_jira_get.pl line 65.
description = 한글 테스트.
F:\ideaic\perl\site\lib>

However, a "wide character in print at" error occurs.
So I changed the Perl parameter as shown below.

Active code page: 65001

F:\ideaic\perl\site\lib>perl -CS ideaic_interface_jira_get.pl
summary = Issues like this one that are marked as fixed in a released version do not show up in Work mode but are included in the reports
description = 한글 테스트.
F:\ideaic\perl\site\lib>

Thank you very much.

0 votes
Matthias Gaiser _K15t_
Community Champion
February 12, 2019

Hi @alex seol,

it might be that you're getting better results when you post this question on the Atlassian Developer community.

But I'll try to give you an answer nevertheless. It looks like you're calling the endpoint: http://company.domaiin:8080/issue/SMPKB-16, but you should call http://company.domaiin:8080/rest/api/2/issue/SMPKB-16 instead.

Checkout the REST API docs about get issue.

Cheers,
Matthias.

alex seol February 13, 2019

Hi, Matthias.

Thank you for your explanation.

The reason I used "http: //company.domainin: 8080 / issue / SMPKB-16" is because I use the "JIRA :: REST" module (see previous mail).

If I want to use the JIRA REST API directly without using the "JIRA :: REST" module (Perl), what do I need to "USE" in a Perl environment?

You can not understand because there is no sample at https://docs.atlassian.com/software/jira/docs/api/REST/8.0.0/#api/2/issue-getIssue.

And using http: //company.domainin: 8080 / rest / api / 2 / issue / SMPKB-16, the following error occurs.

get issues 1.png

Cheers,

Alex

Matthias Gaiser _K15t_
Community Champion
February 13, 2019

I see, thank you for your explanations and actually showing the error message. I'm afraid I cannot help here. As I stated earlier, please head over to the Atlassian Developer Community. More people might be able to help you there.

Or maybe someone else jumps in :)

alex seol February 13, 2019

Hi, Matthias

Thank you.

First of all, I will be waiting for someone else's help.

Cheers,

Alex

Suggest an answer

Log in or Sign up to answer