Unable to set number value in Jira custom field Edited

I'm trying to modify the value of a custom field in Jira.

I do it through the following Curl:

curl -D- -u 'x:y' -X PUT --data '{"fields":{"customfield_67":{"value":18}}}' -H "Content-Type: application/json" https://host/jira/rest/api/2/issue/PRUEBAS-315

Modifying strings I don't have problems, but I do trying to modify this when it is a number. Even though I am sending a number, it tells me that it is not. I have followed the documentation:

https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/

Can someone tell me what I'm doing wrong?

Thank you very much.

**********************************

Code: 400

Response:  {"errorMessages":[],"errors":{"customfield_67":"Operation value must be a number."}}

/jira/rest/api/2/issue/test-2/editmeta:

  "customfield_67":{  
     "required":false,
     "schema":{  
        "type":"number",
        "custom":"com.atlassian.jira.plugin.system.customfieldtypes:float",
        "customId":182
     },
     "name":"Unit Tests Coverage",
     "operations":[  
        "set"
     ]
  },

1 answer

0 votes

There are different ways to provide this kind of field update via REST.  You can either use the update parameter or the fields parameter (just don't try to use both in the same payload for the same field).  But when you make use one of these or the other, the syntax can be slightly different.

When you use the fields parameter like you did here, you actually don't need to use the term 'value' before providing the value.  Instead you could just set your data payload to be:

{"fields":
{"customfield_67":18}
}

To set that field value to a number of 18.

Alternatively, you could use the update parameter, in which case, you can use a slightly different syntax of 'set' such as:

{"update":
{"customfield_67":[{"set":18}]}
}

Either one of these should work for a custom field that has appears on the screen and in turn has that same editmeta response as yours does.

I hope this helps.

Andy

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 14, 2019 in Jira

Updates to jira.atlassian.com give you visibility into what's coming in Jira Server and Data Center

Hello, Community! My name is Gosia and I'm a Product Manager on Jira Server and Data Center here at Atlassian. Since 2002 when we launched our public issue tracker, jira.atlass...

644 views 1 15
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