Jython to create an issue

I have been using Jython script to create an issue and few sub-tasks but after upgrading from v5.0.7 to 6.1.7 get following error to create a ticket.

Error creating issue: root cause: Traceback (most recent call last): File "", line 16, in TypeError: createIssue(): 1st arg can't be coerced to com.atlassian.crowd.embedded.api.User, String

Here is my jython script

#add all required imports here

from com.atlassian.jira import ComponentManager

from com.atlassian.jira.util import ImportUtils

from com.atlassian.jira import ManagerFactory

from com.atlassian.jira import ManagerFactory

issueManager = ComponentManager.getInstance().getIssueManager()

issueFactory = ComponentManager.getInstance().getIssueFactory()

authenticationContext = ComponentManager.getInstance().getJiraAuthenticationContext()

subTaskManager = ComponentManager.getInstance().getSubTaskManager()

issueObject = issueFactory.getIssue()

issueObject.setProject(issue.getProject())

issueObject.setIssueTypeId("168")

issueObject.setParentId(issue.getId())

issueObject.setPriority(issue.getPriority())

issueObject.setSummary("create sub-task")

issueObject.setReporter(issue.getReporter())

subTask = issueManager.createIssue(authenticationContext.getUser(), issueObject)

subTaskManager.createSubTaskIssueLink(issue.getGenericValue(), subTask, authenticationContext.getUser())

ImportUtils.setIndexIssues(True)

ComponentManager.getInstance().getIndexManager().reIndex(subTask)

ImportUtils.setIndexIssues(False)

The one bold are 16 and 17 lines and not sure why am i getting this error. Any help woul appreciate ?

GPK

4 answers

This widget could not be displayed.

JIRA changed user APIs in 5.2. You will have to upgrade your scripts. Google should help you find related information.

This widget could not be displayed.

Bob,

Thanks for the response. Wondering how user API is related to Jython script which is native in Jira.

Can you help provide more details please ?

Padmesh,

Try replacing authenticationContext.getUser() with authenticationContext.getLoggedInUser() and your scrit should work

This widget could not be displayed.

Padmesh,

Try replacing authenticationContext.getUser() with authenticationContext.getLoggedInUser() and your scrit should work

This widget could not be displayed.

thanks Manish it helped.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted 10 hours ago in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

27 views 3 4
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you