Adding worklog examples in documentation uses asApp. How to specify the user?

Looking at The Jira Cloud platform REST API (atlassian.com) I can see that Forge code example uses API to send work logs asApp().

But I cannot find in the docs how to pass the user I want to log work for to the API call. Should I add this to the call body:

author": {"accountId": "5dcf2199da96250c5fcxxxxx"}

It depends who you are trying to log work for.

If the current user (ie the one viewing your issue glance etc. ) is the one you would like to log time for, then simply using asUser() would be the best approach IMO, this also has the advantage that in the issue history it corectly shows that the user is creating the worklog.

If you are logging work after something like a web trigger event, where you don’t have a current user, I think you will have to use asApp and set the author manually.

Exactly, this is my question, using it asApp() how to set the user manually? I cannot find paylod specs for user in the rest api docs for jira cloud… so I hope for an example

Ok, I think based on this [JRACLOUD-30197] Log work via REST API for a given user - Create and track feature requests for Atlassian products., that this is not currently possible. I know in our connect based app to do so we have to impersonate the specific user we would like to log work for, using the Oauth impersonation features. However, I don’t think forge currently supports impersonating users that aren’t directly making the original request.

I guess the best avenue is to raise this as a feature request to impersonate specific users (if such a request does not already exist).

Ie for atlassian to add something like: api.asUser("5dcf2199da96250c5fcxxxxx")...

Hi @RichardVencu! As @richard.white said, user impersonation is not supported by Forge. Any chance you can work it around using asUser()?

1 Like

Thank you. I already did it using asUser() but then I want to prevent users to access the default logging interface

While for the on premise Jira installations this seem possible by disabling some modules from System it is not possible in Jira Cloud

So I thought maybe I can remove users from work log permission and log it asApp() by using the user data as a parameter. Impersonation would not help I suppose