Reporting issues in YouTrack automatically

Problem When working on my side-project for my client, I often require some specific data to address


When working on my side-project for my client, I often require some specific data to address reported issue. It could be a specific request with its body, logged exception with a stack trace or authenticated user's context. I've learned, that expecting someone to paste all necessary data when reporting an error, always fails - remembering each time what you have to include is both tiresome and burdersome. Fortunately there's a possibility to automate things.


Currently I am using YouTrack so I'll stick to this issue tracker only. YouTrack exposes a REST API, which allows you to easily create, delete and manage reported issues. A reference to this API can be found here. Although it is possible to write your own client, I decided to use YouTrackSharp library - for my expectations it is a reasonable choice.

For now I've been missing following data in most issue reporting cases:

  • lack of full request's body - how to reproduce a problem without knowing what was sent to the server, especially when Jil sometimes goes crazy during deserialization
  • lack of user's context - how to reproduce problem without knowing who exactly performed a request
  • lack of headers sent and all request related data

Because I've already been catching all unhandled exceptions to log them, finding a place to call my "CreateYouTrackIssue" method is a piece of a cake. To be honest, I could take advantage of using EventStore and just raise an event, which will be further proceeded - maybe in the future I recreate it this way.

Whole method could look like this:

private static void CreateYouTrackIssue(Exception ex, Stream body)
      using (var reader = new StreamReader(body))
            var conn = new Connection("host", 8080);
            conn.Authenticate("user", "password");

            var json = reader.ReadToEnd();

            dynamic issue = new Issue();
            issue.ProjectShortName = "SOME_NAME";
            issue.Summary = "API error - " + ex.Message;
            issue.Description = string.Format(
                    "An API error occuredd: :\r\nJSON: {0}\r\nStackTrace: {1}",
            issue.Assignee = "root";
            issue.Type = "Bug";
            issue.State = "New";

            var im = new IssueManagement(conn);


This is just a sketch so it doesn't contain all mentioned features but note few things:

  • I'm passing stream to read its content - to get all necessary data passing some request's context would be more practical
  • I'm not handling HTTP connections - YouTrackSharp takes care of it
  • I'm assigning each feature to the root user - you can select whatever user you want

Because Issue() is dynamic, you can pass every custom field you created in YouTrack.


Above solution has already saved me some time when trying to reproduce reported error. What is more, it makes my client happy - he knows, that each time he sees a red error alert, issue has been created and I have been notified about it.

Comments (1) -

324867 467301I wan�t going to comment as this posts a bit old now, but just wanted to say thanks. 115217

Add comment