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

Hugo Lorenzo Mato Feb 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

0 votes
Andrew Heinzer Atlassian Team Feb 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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

1,009 views 13 15
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you