It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Apr 09, 2019 in Portfolio for Jira

Portfolio for Jira 3.0 is here!

The wait is over... Portfolio for Jira Server and Data Center 3.0 is now officially here! Platform releases offer Atlassian an opportunity to shift our strategy, make bold predictions about t...

1,294 views 12 25
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