Hi community,
I've developed a custom rest plugin with routines to automate some of my team tasks.
I am using scripts in post-functions to run the rest API's:
(...)
def issueRest = remote.request(Method.POST,ContentType.JSON) { req ->
uri.path = ("/rest/myrest/latest/mymethod")
headers.'Authorization' = "Basic ${"defaultusers:pass".bytes.encodeBase64().toString()}"
body = [
"skuList" : arrayOfSkus,
"customFieldModelsList" : [
[ "name" : "Customfield 01", "value" : "Value 01" ],
[ "name" : "Customfield 02", "value" : "Value 02" ]
]
]
response.success = { resp6,json ->
log.warn "Success! ${resp6.status}"
}
response.failure = { resp6,json ->
log.warn "Request failed with status ${resp6.status}"
}
}
(...)
The code is working perfectly. But, the changes will always be made with the default user.
I need to change the "defaultuser" to the current user. But, the ApplicationUser (com.atlassian.jira.component.ComponentAccessor.getJiraAuthenticationContext().getUser()) doesn't have the password value or any value related to the session.
How can I do it?
Best Regards.