JetBrains / YouTrackSharp

.NET Standard 2.0 Library to access YouTrack API.
https://www.jetbrains.com/youtrack
Apache License 2.0
135 stars 105 forks source link

How to create a new issue? #95

Open WKleinschmit opened 4 years ago

WKleinschmit commented 4 years ago

Hello, I'm using version 2019.2.0 on a version on a 2019.2 server and I want to create a new issue. This is my code:

                        BearerTokenConnection connection = new BearerTokenConnection(
                            "https://youtrack.example.com/",
                            "perm:Ym...Dfg");

                        IIssuesService issuesService = connection.CreateIssuesService();

                        YouTrackSharp.Issues.Issue ytIssue = new YouTrackSharp.Issues.Issue
                        {
                            Summary = summary,
                            Description = descriptionBuilder.ToString(),
                        };

                        string ytIssueID = await issuesService.CreateIssue("SIMNC", ytIssue);

During the call to CreateIssue my program just ends without any error message and the issue is not created. What am I doing wrong?

maartenba commented 4 years ago

Nothing, it seems :-) Code is similar to the test we have here, so that should be good.

Any chance you could try to add a try/catch around it or use another means of capturing the unexpected end of your app?

WKleinschmit commented 4 years ago

I've tried the same call using the RestSharp library and it turns out the issue creation fails with a "BadRequest" response due to some workflow that is denying access. (Issue to our IT is pending,)

But still, that should not make the whole program just vanish. And no, a try/catch block around the call does nothing. Looks like there is no exception to catch, the program is just aborted.

maartenba commented 4 years ago

YouTrackSharp throws an exception when this happens, the app/.net runtime should be able to handle that gracefully.

Wondering if you have some code we could use to reproduce the issue?