0

I'm trying to create a new issue using YouTrackSharp, back into my on premise you track instance. I can search fine, so I know my Connection and Credentials are working.

Based on the example I have tried both a dynamic, as well as instantiating an Issue().

Fails to Compile

dynamic issue = new Issue()
{
    type = "Question",
    summary = model.Summary,
    description = model.Description,
    projectShortName = "CSR",
};

This code compiles, but Fails at runtime to convert dynamic into Issue param, with exception ' The best overloaded method match for 'YouTrackSharp.Issues.IssueManagement.CreateIssue(YouTrackSharp.Issues.Issue)' has some invalid arguments

dynamic issue = new
{
    type = "Question",
    summary = model.Summary,
    description = model.Description,
    projectShortName = "CSR",
};
YouTrackIssueManager().CreateIssue(issue);

1 Answer 1

1

To Find The Answer I found on the github repo about Breaking changed in 2.0 - and then it goes on to talk about reading the specs for examples.

Exerpt:

Issue is now a dynamic type. To work with it, you need to declare an issue as dynamic. The only fixed field it has is "Id" (although later on some others might be added). The reason for this is that it is now inline with how YouTrack works itself which is that every field in an issue is basically a custom field. You can now have as many or as little custom fields as you like! This was a major change in 2.0 and is incompatible with existing code unfortunately.

The answer/code that worked is, using a combination of Dynamic and new Issue() (which was new syntax for me, that i'm now looking further into).

dynamic issue = new Issue();
issue.Type = "Question";
issue.Summary = model.Summary;
issue.Description = model.Description;
issue.ProjectShortName = "CSR";
YouTrackIssueManager().CreateIssue(issue);

Thanks @hhariri for your work on this project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.