c# Updating Custom Time Field

Kevin Sugihara October 29, 2013

I'm updating a custom time field, customfield_10000.

When I set this field via the web interface, and do a REST call to get the issue, data is returned in the field.

When I try http://localhost/rest/api/latest/customFieldOption/10000 however, I get the response:

{
  "errorMessages": [
    "A custom field option with id '10000' does not exist"
  ],
  "errors": {}
}

Even weirder, when I try to set the value,

{
  "update": {
    "customfield_10000": [
      {
        "set": {
          "value": "2013-10-28T18:17:00.000-0700"
        }
      }
    ]
  }
}

I get the error

{
  "errorMessages": [],
  "errors": {
    "customfield_10000": "Operation value must be a string"
  }
}

Can someone offer some insight as to what is exactly going on here?

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Aleksander Mierzwicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 29, 2013

So, looking at the documentation (https://docs.atlassian.com/jira/REST/latest/#d2e1272) I guess that you should PUT JSON like that:

{
"fields":
{
"customfield_10000": "2013-10-28T18:17:00.000-0700"
}
}

The command below:

curl -X PUT -H 'Content-Type: application/json' -u admin:admin http://my-test-instance/rest/api/2/issue/TST-77 -d '{"fields":{"customfield_11000":"2013-10-28T18:17:00.000-0700"}}'

Worked fine for me, so the given JSON body should be fine.

Afaik the "update" part of JSON body is for adding/deleting items (like comment or worklog), not for setting field values like date-time. A bit confusing but that's how it works.

Kevin Sugihara October 29, 2013

Ah man I didnt notice. It should be parent object Fields not Update. My mistake. Thank you Aleksander!

0 votes
Kevin Sugihara October 29, 2013
Would you mind explaining why the Json I have above is not working?
0 votes
Aleksander Mierzwicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 29, 2013

Custom field option is not the same that custom field. Custom field option is for example an item in single select field.

If you want set value of customfield you need to edit issue (PUT for issue resource) or transition it if your field is on the proper screen (but I guess that you want just update issue).

Kevin Sugihara October 29, 2013

Would you mind explaining why the Json I have above is not working? I am performing a PUT request to http://localhost/rest/api/latest/issue/SI-3965 with the Json above.

0 votes
Kevin Sugihara October 29, 2013

If it helps, here is the editmeta for my issue:

"customfield_10000":
       {
           "required": false,
           "schema":
           {
               "type": "datetime",
               "custom": "com.atlassian.jira.plugin.system.customfieldtypes:datetime",
               "customId": 10000
           },
           "name": "First Observed",
           "operations":
           [
               "set"
           ]
       },

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events