I have a post function where I create an attachment and attach it to the issue.
The attachment contains information from assets.
In order to obtain the assets information I am using the assets API call this way:
I created a token and declared as def ASSETS_TOKEN = "xxxYYY..."
curl --request GET \
--url 'https://api.atlassian.com/jsm/assets/workspace/eaf0753d-5b96-4a5c-b99f-068797206587/v1/object/151' \
--header 'Authorization: Bearer XXXYYYZZZ...' \
--header 'Accept: application/json'
Throws 401 Unauthorized
curl --request GET \
--url 'https://api.atlassian.com/jsm/assets/workspace/eaf0753d-5b96-4a5c-b99f-068797206587/v1/object/151' \
--user 'validemail@somewhere.com:XXXYYYZZZ...' \
--header 'Accept: application/json'
Works fine
I believe the token to use with Authorization: Bearer has to be composed using the email of the user and the token.
Then I attach a file
So question is, how can this be fixed.
What I need is that the history shows as autor of the attachment change the user that performed the issue transition triggering the post function.
Hi @Petru Simion _Simitech Ltd__
In Cloud, post-functions run via the ScriptRunner app user context (not the user who triggered the transition), so Users.getLoggedInUser() (or getLoggedInUser() in Groovy) will return the ScriptRunner add-on account.
If you need to run actions as the real user, update the post-function settings to:
Run as → Initiating User
This ensures the script executes with the identity of the user who triggered the workflow transition, and getLoggedInUser() will return their account context.
If you're already doing that and still seeing the add-on user, it might be because the transition was triggered by automation or another app — in such cases, there's no actual user to impersonate.
Workaround:
If "Run as Initiating User" isn’t viable (e.g. due to app-based triggers), you can retrieve the last transition author from the issue changelog via the REST API:
GET /rest/api/3/issue/{issueKey}?expand=changelog
Look for the latest status change and extract the author.accountId field.
Kind Regards
Utkarsh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.