Forums

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

I want to update the custom field value of a specific issue using the JIRA REST API in perl env.

alex seol April 3, 2019

Hi, team.

In the Perl environment, I want to update the custom field value of a specific issue using the JIRA REST API.

1 CASE:
my $issue_progress = $jira -> POST("/issue/".$row[12]."");
fields => {
customfield_10221 => $vprogress
};
2 CASE:
my $issue = $jira -> POST('/issue', undef, {
fields => {
issue => {id => $row[12]},
customfield_10221 => $vprogress
},
});
3 CASE:
my $issue_progress = $jira->POST('/rest/api/2/issue/'.$row[12], undef, {
fields => {
customfield_10221 => $vprogress
}});

'$ row [12]' is the Issue id.

I have tested all three methods above. However, errors occur.

I saw https://docs.atlassian.com/software/jira/docs/api/REST/8.0.0/#api/2/issue-editIssue. But I do not know.

Waiting for help from experts.

 

thank you.

alex.

 

2 answers

1 accepted

0 votes
Answer accepted
alex seol April 9, 2019

Hi, Gonchik

I solved it. I modified the source as shown below.

my $issue_progress = $jira->PUT('/rest/api/2/issue/'.$row[12]., undef, {                            fields => { customfield_10221 => $vissue_progress }});print "The '".$row[12]."' issue progress has been updated successfully. \n";

Thank you.

Alex.

0 votes
Gonchik Tsymzhitov
Community Champion
April 3, 2019

Hi! 

Do you use Jira 8.0.0 ?

And could you provide some errors here ?

I use it like that in python

https://github.com/atlassian-api/atlassian-python-api/blob/master/examples/jira-custom-field-value-swaper.py

 

 

Cheers,

Gonchik Tsymzhitov

alex seol April 4, 2019

Hi, Gonchik

We are using jira 7.12.3

I did not get any special errors, so I used eval {}. (below)

eval {
my $issue = $jira -> GET("/issue/".$row[12]."");
print "The issue key '".$row[12]."' exist.(in Jira) \n";
# 2. Gets the status of the Jira issue key that matches the issue key.(below)
my $fields = $issue->{fields};
my $status = $fields->{status};
my $vStatus = $status->{id};
my $assignee = $fields->{assignee};
my $vProgress = $fields->{progress};
my $vissue_progress;
if (defined $vProgress->{percent}) {
print "Message(1): progress.percent = $vProgress->{percent}% \n";
$vissue_progress = $vProgress->{percent};
} else {
print "Message(1): progress.percent field has not value.(in Jira) \n";
}

# 3. status is 10000. 'To Do' does not get the field value of 'Jira'.(below)
if ($vStatus eq '10000') {
print "break point : status is 10000. 'To Do' does not get the field value of 'Jira'. \n";
# 4. status is 3. 'In Progress' does get the field value of 'Jira'.
# 5. status is 10001. 'Done' does last get the field value of 'Jira'.
} else {
print "break point : status is 3 or 10001'. \n";
# my $issue_progress = $jira -> POST("/issue/".$row[12]."");
# fields => {
# customfield_10221 => $vprogress

# };
# my $issue = $jira -> POST('/issue', undef, {
# fields => {
# issue => {id => $row[12]},
# customfield_10221 => $vprogress
# },
# });
my $issue_progress = $jira->POST('/rest/api/2/issue/'.$row[12].'editmeta', undef, {
fields => {
customfield_10221 => $vissue_progress
}});
print Dumper($issue_progress);
print "The progress has been updated successfully. \n";
}
};
if ($@) {
print "Message(1): The issue key '".$row[12]."' does not exist.(in Jira) \n";
}

I understood what you mean by the Python code you gave me.

However, it can not be converted to Perl.

I need help with Perl code.

thank you.

alex.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events