Unable to set number value in Jira custom field

hugo-lorenzo-mato February 14, 2019

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

1 vote
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 21, 2019

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