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

**URL:** <https://community.developer.atlassian.com/t/i-want-to-print-only-specific-field-values-of-a-specific-issue/26992>\
**Category:** Jira Server\
**Created:** [February 14, 2019, 6:58am UTC](https://community.developer.atlassian.com/t/i-want-to-print-only-specific-field-values-of-a-specific-issue/26992 "2019-02-14T06:58:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![netdynamics](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@netdynamics](https://community.developer.atlassian.com/u/netdynamics)\
**Post date:** [February 14, 2019, 6:58am UTC](https://community.developer.atlassian.com/t/i-want-to-print-only-specific-field-values-of-a-specific-issue/26992/1 "2019-02-14T06:58:08Z")

</div>

## Hi, everyone. 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](http://www.ideaic.co.kr: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.

---

<div class="post-metadata">

**Author:** ![ianRagudo](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/ianragudo/32/44527_2.png) [@ianRagudo](https://community.developer.atlassian.com/u/ianRagudo)\
**Post date:** [February 14, 2019, 7:27am UTC](https://community.developer.atlassian.com/t/i-want-to-print-only-specific-field-values-of-a-specific-issue/26992/2 "2019-02-14T07:27:42Z")

</div>

Hello @netdynamics,

If you only want to return specific fields while using [Get issue](https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/issue-getIssue), use the query parameter `fields` then specify the fields you need. So for example your GET request will look something like `/rest/api/2/issue/SMPKB-16?fields=summary,description`.

Do try it out and see if that is what you need.

EDIT:  
Upon re-reading the post a number of times, are you more interested about parsing the response body only?

Cheers,  
Ian

---

<div class="post-metadata">

**Author:** ![netdynamics](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@netdynamics](https://community.developer.atlassian.com/u/netdynamics)\
**Post date:** [February 14, 2019, 5:25pm UTC](https://community.developer.atlassian.com/t/i-want-to-print-only-specific-field-values-of-a-specific-issue/26992/3 "2019-02-14T17:25:45Z")

</div>

Hi, iragudo.  
Thank you for your explanation.  
But my “my $ issue = $ jira -\> GET (” / issue / SMPKB-16? “);” Is “my $ jira = JIRA :: REST -\> new”. It is a JIRA :: REST perl module.  
So I can not change “my $issue = $jira -\> GET(”/issue/SMPKB-16?");" to “my $issue = $jira -\> GET(”/rest/api/2/issue/SMPKB-16?");".

So I changed and tested as below.

my $issue = $jira -\> GET("/issue/SMPKB-16?fields=summary,description");  
my $json\_text = do {  
open(my $json\_fh, “\<:encoding(UTF-8)”, $issue) or die (“Can’t open $issue”: $!\n");  
local $/;  
\<$json\_fh\>  
};

The following error occurs.  
F:\ideaic\perl\site\lib\>perl ideaic\_interface\_jira\_get.pl  
Can’t open $issue": No such file or directory  
F:\ideaic\perl\site\lib\>

I printed the “$issue” value. The results are as follows.  
get issue: HASH(0x3170d38)

The “hash” value appears to be entering.  
How do I print ‘summary’ and ‘description’ values?  
Cheers,  
Alex

---

<div class="post-metadata">

**Author:** ![ianRagudo](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/ianragudo/32/44527_2.png) [@ianRagudo](https://community.developer.atlassian.com/u/ianRagudo)\
**Post date:** [February 15, 2019, 5:51am UTC](https://community.developer.atlassian.com/t/i-want-to-print-only-specific-field-values-of-a-specific-issue/26992/4 "2019-02-15T05:51:43Z")

</div>

Hello @netdynamics,

HASH is being returned by `my $issue = $jira -> GET("/issue/SMPKB-16?fields=summary,description");` in which I think is workable for us. Dumping $issue via `Dumper($issue)` and printing it results in

```auto
$VAR1 = {
          'key' => 'TEST-7',
          'self' => 'http://localhost:2990/jira/rest/api/latest/issue/10100',
          'id' => '10100',
          'expand' => 'renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations',
          'fields' => {
                        'summary' => 'This is a test issue',
                        'description' => 'This is a test description for Perl test'
                      }
        };

```

In order to get the summary and description, here’s what I did:

```auto
my $issue = $jira -> GET("/issue/TEST-7?fields=summary,description");
my $fields = $issue->{fields};
print "summary = $fields->{summary}\n";
print "description = $fields->{description}\n";

```

which resulted in

 ![image](https://global.discourse-cdn.com/atlassiandeveloper/original/3X/6/0/60912dff118f1017c94b6159fb1febeaa38a94ec.png)

Disclaimer:

1. I only tried perl an hour or so ago to help you with this question, there might be a better way to optimize the code.
2. JIRA::REST module is new to me too as it is not an Atlassian supported module

I think this should work with your use case.

Cheers,  
Ian

---

<div class="post-metadata">

**Author:** ![ianRagudo](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/ianragudo/32/44527_2.png) [@ianRagudo](https://community.developer.atlassian.com/u/ianRagudo)\
**Post date:** [February 19, 2019, 10:58pm UTC](https://community.developer.atlassian.com/t/i-want-to-print-only-specific-field-values-of-a-specific-issue/26992/5 "2019-02-19T22:58:10Z")

</div>

Hi @netdynamics, does this solve your original question?

---

<div class="post-metadata">

**Author:** ![netdynamics](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@netdynamics](https://community.developer.atlassian.com/u/netdynamics)\
**Post date:** [February 20, 2019, 1:27am UTC](https://community.developer.atlassian.com/t/i-want-to-print-only-specific-field-values-of-a-specific-issue/26992/6 "2019-02-20T01:27:47Z")

</div>

Hi, Ian  
I sincerely appreciate your help.  
I solved it because of your help.  
Cheers,  
Alex.
