The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Unable to add workload in script runner post function.

Zbyszek
Contributor
August 14, 2020

Hello

I want to increase the time spend on an issue when the issue is changing its status. For that purpose, I'm using script runner post function with following script:

def issueKey = issue.id

def result = put("/rest/api/3/issue/${issueKey}/worklog")
.header('Content-Type', 'application/json')
.body([
timeSpent: '2h'
]).asString()

But always as a result I'm getting "status: 405 - Method Not Allowed".

It happens no matter whether I run it as a ScriptRunner Add-On User or Initiating User.

I've tried similar, external python script with the same user and it worked. When instead of timeSpent I've tried elapsedTime it also worked properly.

Anyone can help, where am I doing a mistake? Or maybe it's not possible to update the timeSpent from scriptRunner?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
August 15, 2020

hi @Zbyszek  the problem is that you are using "put" method to update worklog, but it would work only to update existing worklog.

I will try to describe it little bit. You have an issue object and every log work operation creates new worklog entry, so you can have multiple worklogs on one issue.

  • POST method creates NEW entry
  • PUT method updates EXISTING entry

If it is ok just to add new worklog, you can use:


def result = post("/rest/api/3/issue/${issueKey}/worklog")
.header('Content-Type', 'application/json')
.body([
timeSpent: '1h'
]).asString()
Zbyszek
Contributor
August 16, 2020

Thank you, that worked perfectly :).

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events