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 vote
Alexey Matveev Community Champion Jan 05, 2018

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.

Alexey Matveev Community Champion Jan 08, 2018

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?

Alexey Matveev Community Champion Jan 08, 2018

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.

Alexey Matveev Community Champion Jan 08, 2018

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

Alexey Matveev Community Champion Jan 08, 2018

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

773 views 2 19
Join discussion

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