Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Update timeSpent field


Can someone explain to me why my code is bad?



I put my code:


def time = "1m"

def result2 = put("/rest/api/2/issue/${linkKey}")
.header('Content-Type', 'application/json')
.queryString("overrideScreenSecurity", Boolean.TRUE)
fields: [
worklog: [
timeSpent: time
if (result2.status >= 200 && result2.status < 300) {'success 2')
} else {
return "${result2.status}: ${result2.body}"

1 answer

1 accepted

1 vote
Answer accepted

Hi Eduard,

Thank you for your question above.

I can confirm that in order to log work on an issue that you need make a call to the Update Worklog rest API which Atlassian have documented here passing the parameters outlined on this page in order to update a worklog.

The rest endpoint that you are calling inside of your script is incorrect which is the reason why you are unable to add a worklog to an issue, and you will need to use the endpoint outlined in the API documentation page above to set a worklog on an issue.

I have created an example script which you can view here which shows how you can update the time spent value for a worklog on an issue and you will be able to take this example script and use it as a reference to create the script that you require to achieve your requirements.

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.



Thank's for the repository

What did you use to import for put method?

Hi Pritesh,

If you are using ScriptRunner for Jira Cloud then you do not use any imports as ScriptRunner for Jira Cloud comes bundled with UniRest as mentioned in the documentation page located here.

Kind Regards,


Using data center. 

Hi Pritesh,

Thank you for your response.

This post here is around Jira Cloud so I would advise you to post a new answer tagged as Jira Data Center so someone familiar with ScriptRunner for Jira Data Center can advise on this.

In the meantime, I noticed the script Libray example located here provides an example of making rest requests using the server/ data centre version of ScriptRunner and covers Put requests which you may find helpful.



Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

#JiraHeroes May '22 Spotlight: Daniel Cave

At Atlassian, we take great pride in the software we ship, and even greater pride in the success our customers achieve when they use our products. #JiraHeroes is our new monthly spotlight series&nbsp...

857 views 0 8
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