Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

How to log work then resolve issue using rest api?

Hi all.

I try to resolve issue using transition in rest api. So, i send POST request to URL

/rest/api/latest/issue/JMA-105/transitions?expand=transitions.fields&transitionId=5

with POST data:

{
"transition":{"id":"5"},
"\"update\"":{
    "comment":[
        {"add":{"body":"same comment"}}
    ]
},
"fields":{
    "assignee":{"name":"-1"},
    "resolution":{"self":"https://guffer4.atlassian.net/rest/api/latest/resolution/1","name":"Fixed","id":"1"},
    "worklog":{"timeSpent":"10m"}
}
}

And server return responce with code 400 {"errorMessages":[],"errors":{"worklog":"Field does not support update 'worklog'"}}.

if i dont send in POST data fields.worklog issue resolved correctly, bat comment not added.

What structure of the POST data is correct if i need add comment and log work?

thanks in advance.

PS: sorry for my english.

2 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

To update worklog while transitioning issue you have to pass worklog item in "update" section, like you do with comment:

{
  "update": { 
    "worklog" : [ 
      { 
        "add": { 
          "timeSpent" : "6m" 
        } 
      } 
    ] 
  },
  "transition" : { 
    "id" : "4"
  } 
}

Cheers,
Alek.

thanks Alek. its work. I use it in my app for jira free and paid versions

Saved my day :D

0 votes
Fahd Atlassian Team Feb 20, 2013

Hi Pavel,

Please check whether the field worklog is available to be updated during that transition. You can request using /rest/api/2/issue/{issueIdOrKey}/transitions?expand=transitions.fields to check the list of fields that are available.

If worklog field is not in the list, try to add worklog field in the trasition's screen in JIRA UI. Once added, check the list again.

From the documentation here:

" If a field is not configured to appear on the transition screen, then it will not be in the transition metadata, and a field validation error will occur if it is submitted."

Checking the list of available response for code 400, it does match your current problem now which due to the field is not available.

Hope this helps.

Regards,

Fahd

Hi Fahd,

for geting fields for transition i use url /rest/api/2/issue/{issueIdOrKey}/transitions?expand=transitions.fields&transitionId=5 and create form dinamicly based on response. This response is:

{"expand":"transitions","transitions":[{"id":"5","name":"Resolve Issue","to":{"self":"https://guffer4.atlassian.net/rest/api/2/status/5","description":"A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.","iconUrl":"https://guffer4.atlassian.net/images/icons/status_resolved.gif","name":"Resolved","id":"5"},"fields":{"assignee":{"required":false,"schema":{"type":"user","system":"assignee"},"name":"Assignee","autoCompleteUrl":"https://guffer4.atlassian.net/rest/api/latest/user/assignable/search?issueKey=JMA-105&username=","operations":["set"]},"fixVersions":{"required":false,"schema":{"type":"array","items":"version","system":"fixVersions"},"name":"Fix Version/s","operations":["set","add","remove"],"allowedValues":[]},"resolution":{"required":true,"schema":{"type":"resolution","system":"resolution"},"name":"Resolution","operations":["set"],"allowedValues":[{"self":"https://guffer4.atlassian.net/rest/api/latest/resolution/1","name":"Fixed","id":"1"},{"self":"https://guffer4.atlassian.net/rest/api/latest/resolution/2","name":"Won't Fix","id":"2"},{"self":"https://guffer4.atlassian.net/rest/api/latest/resolution/3","name":"Duplicate","id":"3"},{"self":"https://guffer4.atlassian.net/rest/api/latest/resolution/4","name":"Incomplete","id":"4"},{"self":"https://guffer4.atlassian.net/rest/api/latest/resolution/5","name":"Cannot Reproduce","id":"5"}]},"worklog":{"required":false,"schema":{"type":"array","items":"worklog","system":"worklog"},"name":"Log Work","operations":["add"]}}}]}

as you can see (at the end of string) worklog is in response.

TAGS
Community showcase
Published in Marketplace Apps & Integrations

Delivery and Operations Teams can be more Effective and Profitable

    Managing services end-to-end, optimizing efforts to deliver the best services to customers. This is what team leaders and managers want to achieve. When using a tool like Jira, it...

28 views 0 1
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