Using the YouTrackSharp Nuget package (version 2021.3.6) to create a work item for an existing issue should correctly create the work item in the issue.
YouTrack server on-prem, Build 2022.2.53793, Fri, Aug 19, 2022.
Actual behavior
The request fails with the following error:
YouTrackSharp.Generated.YouTrackErrorException : The HTTP status code of the response was not expected (400).
Status: 400
Response:
{"error":"Bad Request","error_description":"YouTrack is unable to locate an Me-type entity unless its ID is also provided","error_developer_message":"YouTrack is unable to locate an Me-type entity unless its ID is also provided"}
Could not find any reference to this error on my Google searches.
I've triple-checked that the data supplied on the method call is valid and everything "exists" on our YouTrack instance.
The bearer token used is valid and has the necessary service scopes for the operation.
Steps to reproduce the behavior
The following Xunit test triggers the error, you'll just have to supply valid values to the configuration options:
public class YouTrackWorkItemTests
{
private readonly BearerTokenConnection connection;
public YouTrackWorkItemTests()
{
connection = new BearerTokenConnection(
"<youtrack instance url>",
"<bearer token>"
);
}
[Fact]
public async Task ShouldCreateTimeTrackingWorkItem()
{
// Arrange
var issueService = connection.CreateIssuesService();
var timeTrackingService = connection.CreateTimeTrackingService();
var issueId = "<an existing issue id from a project with time tracking enabled>";
var description = "<any description will do>";
var duration = TimeSpan.FromHours(1);
var author = "<a valid user name with access to the project>";
// Act
var issue = await issueService.GetIssue(issueId).ConfigureAwait(false);
var workItemTypes = await timeTrackingService.GetWorkTypesForProject(issue.GetField("projectShortName").AsString()).ConfigureAwait(false);
var workItem = new WorkItem(
DateTime.UtcNow,
duration,
description,
workItemTypes.First(),
new Author { Login = author });
var workItemId = await timeTrackingService.CreateWorkItemForIssue(issue.Id, workItem);
// Assert
workItemId
.Should()
.NotBeNullOrEmpty()
.And
.NotBeNullOrWhiteSpace();
}
}
Expected behavior
Using the YouTrackSharp Nuget package (version 2021.3.6) to create a work item for an existing issue should correctly create the work item in the issue.
YouTrack server on-prem, Build 2022.2.53793, Fri, Aug 19, 2022.
Actual behavior
The request fails with the following error:
Could not find any reference to this error on my Google searches.
I've triple-checked that the data supplied on the method call is valid and everything "exists" on our YouTrack instance. The bearer token used is valid and has the necessary service scopes for the operation.
Steps to reproduce the behavior
The following Xunit test triggers the error, you'll just have to supply valid values to the configuration options:
Any help is appreciated! Thanks!