YouTrackSharp
YouTrackSharp copied to clipboard
Create WorkItem with Author
When I try to create WorkItem with Author field I get an exception
Response status code does not indicate success: 403 (Forbidden).
I think it is because method CreateWorkItemForIssue in YouTrackSharp.TimeTracking.TimeTrackingService call
rest/issue/{issueId}/timetracking/workitem
And in documentation api youtrack I see for this call that is has no author
https://www.jetbrains.com/help/youtrack/standalone/Create-New-Work-Item.html
I think it must be a call with author, described in
https://www.jetbrains.com/help/youtrack/standalone/Import-Workitems.html
but I can't find it in YouTrackSharp
Those are two different API's, the first one is the correct one.
403 effectively means forbidden, so may mean that the user you are creating a work item with has no permission to create a work item, or time tracking is not enabled. Note the work item should also have the correct work item type.
Do you have some more information? What is the call you are making? Do you have time tracking enabled for the project?
Check this unit test for an example: https://github.com/JetBrains/YouTrackSharp/blob/master/tests/YouTrackSharp.Tests/Integration/TimeTracking/CreateWorkItemForIssue.cs
- About the first API - https://www.jetbrains.com/help/youtrack/standalone/Create-New-Work-Item.html - I think that if WorkItem has a constructor with Author I can fill this field. I get 403 only if I fill Author, in other cases all is ok. Ok, I don't fill Author for this API
- About the second API - https://www.jetbrains.com/help/youtrack/standalone/Import-Workitems.html -I need to fix time from other user, not from me, how can I do it with YouTrackSharp?
This is not possible yet. Author is always the user who is making the API call, the second API has not been implemented yet in YouTrackSharp (tracking issue #55)
Worst case if you need it now you can call the API manualy, the connection also exposes an HttpClient:
var client = await _connection.GetAuthenticatedHttpClient();
(and if you happen to go that route, a PR to resolve #55 is only a bit more work ;-))