Is there a way to create an issue as another user?

Hi all,

I'm the administrator of a Standalone YouTrack instance running Build 2020.4.6808. I have a Hub/YouTrack "software account" user with an API token that has full access that I've been using to program around the YouTrack REST API. I'd like to use the API in a programmatic way to create issues based on some input to a separate HTTP service I am running. I know the user's identity in this other HTTP service, and I'd like to be able to create an issue on their behalf and have the YouTrack issue indicate that it was created by that user, and not this software account (whose token is provided in the Authorization header in my calls to POST /api/issues. 

I can see that on https://www.jetbrains.com/help/youtrack/standalone/operations-api-issues.html, `reporter` is a read-only field, so it's not able to be set in the body of the POST call to /api/issues. Is there any way at all to either set the desired reporter at issue creation time, or after the issue is created?

Thanks,
David

1
5 comments

I'm also looking for the same functionality for posting comments. It's not very useful for me to write comments from "sync_account" instead of a properly attributed user.

0

Hello David,

The 'reporter' attribute can be used in POST requests, so it is possible to use a request like this:

curl -X POST https://example.myjetbrains.com/youtrack/api/issues 
...
-d '{
"project":{"id":"0-167"},
"summary":"Some summary",
"description":"Some description",
"reporter":{"id":"1-4"}
}'

Please note that it is needed to use the YouTrack user's ID.
The same is applicable to the 'author' attribute of the comment.

I will ask to edit the documentation accordingly, thank you for bringing our attention to it.

1

Hi Alisa,

This was a big help! Thanks for providing it. I was trying with using the "name" attribute inside "reporter", but good to know that "id" is required.

Thanks,
David

0

As I learned in the neighbouring thread, you can also use ringId instead of id, with the advantage that ringId is now available in the workflows, meaning you don't have to make an extra API call to find the id by login if you are e.g. passing information from a workflow to an external service, and external service has to react.

I think this would be a good idea to add it to the documentation as well.

1

Yury, thank you very much for the input! I've created a task for our writing team, we'll see how we can improve our documentation regarding this point.

0

Please sign in to leave a comment.