Error while trying to update a custom field using REST API

I am trying to implement a functionality to auto close few tickets which meets a criteria. I am getting the errors mentioned below while making the API call to resolve the issue.

Command I am running:

curl -D- -u admin:admin -X POST --data @oracle_decomm_close_2 -H "Content-Type: application/json" "https://jiraxx.xxxx.com/rest/api/2/issue/DECOM-40322/transitions?expand=transitions.fields" 

cat oracle_decomm_close_2
{
"update": {
"comment":[{"add": {"body": "Automatic closure of Oracle decommission ticket"}}],
"worklog":[{"add": {"timeSpent":"1m"}}],
"customfield_14881":{"value": "NO"}
},"transition": {"id": "5"}
}

Error:

{"errorMessages":["Can not deserialize instance of java.util.ArrayList out of START_OBJECT token\n at [Source: com.plugenta.jiraauditor.filter.RestReadingServletRequest$1@388e8ec2; line: 1, column: 139] (through reference chain: com.atlassian.jira.rest.v2.issue.IssueUpdateBean[\"update\"])"]}

 

New to json. Any help on this is highly appreciated.

 

1 answer

0 votes

Hello,

Do you mean that the problem is with customfield_14881? Are you sure about it? Did you try to do the POST without customfield_14881? Did it work? If you are sure that the problem is withcustomfield_14881then what is customfield_14881 custom field type?

Thanks for getting back Alexey.

 

I am not quite sure where the problem is. I figured that customfield_14881 is required to transition the ticket status to "Resolved". It wouldnt let me close the ticket from the front end, if this field is not set.

 

I am not sure how to find the type of the custom field. But I did a GET on an existing ticket, and found the below for this particular custom field.

"customfield_14881": {
"id": "17533",
"self": "https://jiraxx.xxxx.com/rest/api/2/customFieldOption/17533",
"value": "NO"
}

 

Please excuse my mistakes. Any help or guidance is appreciated.

Your JSON should be like this

{
"update": {
"comment":[{"add": {"body": "Automatic closure of Oracle decommission ticket"}}],
"worklog":[{"add": {"timeSpent":"1m"}}]
},

"fields": {
    "customfield_14881":{"value": "NO"}
  },"transition": {"id": "5"}
}

Tried that.

 

I get HTTP/1.1 500 Internal Server Error

 

Can I enable additional logging to see specific errors?

Have a look in your atlassian-jira.log. It should work. The problem was that

"customfield_14881":{"value": "NO"} was in the update parameter. But it must be in the fields parameter. Aslo I supposed that your custom field is a single select

Thanks Alexey.

 

Unfortunately I dont have access to the application logs. I will keep looking to get them.

 

Adding the custom field change to fields parameter still hasn't worked.

What is the error?

I just get this when i execute the curl command.

 

{"errorMessages":["Internal server error"],"errors":{}}

The custom field is indeed single select. From the front end i see the possible options are YES/NO

Try to install Jira REST API browser add-on(it is free) and check it there. You can query all REST API functions there. Have a look what will be the error there.

Thanks Alexey. Turns out the id I gave in the transition was incorrect.

 

It worked after I gave the right one.

 

Thanks for your help.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Jira

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,094 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you