Giter Site home page Giter Site logo

jetbrains / youtracksharp Goto Github PK

View Code? Open in Web Editor NEW
133.0 29.0 104.0 28.89 MB

.NET Standard 2.0 Library to access YouTrack API.

Home Page: https://www.jetbrains.com/youtrack

License: Apache License 2.0

Batchfile 0.01% C# 99.60% PowerShell 0.25% Shell 0.12% jq 0.02%
youtrack youtrack-api jetbrains jetbrains-youtrack

youtracksharp's People

Contributors

aschoelzhorn avatar baranovskis avatar dependabot[bot] avatar elwetana avatar hhariri avatar jawn avatar jeff-french avatar jirkakara avatar johannesg avatar maartenba avatar matkoch avatar mwgriffiths88 avatar nesteruk avatar nylchr avatar rekolobov avatar sbaer avatar tablekat avatar tdietrich513 avatar tetsuo13 avatar tikicoder avatar wallaceturner avatar warhorsestudios avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

youtracksharp's Issues

UserManagementService .CreateUser replaces ' ' with '+'

Expected behavior

We are using UserManagementService .CreateUser (https://github.com/JetBrains/YouTrackSharp/blob/192/src/YouTrackSharp/Management/UserManagementService.cs#L86) for users creating in our library. In case of sending full name like "FirstName LastName" it should create user with the full name equals "FirstName LastName"

Actual behavior

Actually it works wrong and saves it as string "FirstName+LastName". Probably the reason is WebUtilities.UrlEncode on fullName string (this helper replaces ' ' character with the '+' character).

Also, I think this problem is actual for all POST/PUT requests.

Steps to reproduce the behavior

You can just call UserManagementService .CreateUser with FullName parameter that contains spaces.

doesn't support the new API on 2019.1

Expected behavior

getting a list of issues should not get a 404.

Actual behavior

getting a list of issues results in a 404, after our youtrack instance was updated to 2019.1

Steps to reproduce the behavior

Code which broke after Youtrack was updated
https://example.myjetbrains.com/youtrack/rest/issue?filter=test

Steps to solve the problem:

  • Replace "rest" with "api"
  • Replace "issue" with "issues"

So it seems there were multiple breaking changes in the new API Version, which this library does not support at this point.

Update XML documentation: UserManagementService GetUsers only returns 10 users

Expected behavior

GetUsers called without paramters should return all users, not only the first 10 records.
The description says: "Get a list of all available registered users."

Actual behavior

only 10 users are returned

Steps to reproduce the behavior

call GetUsers() without parameters, more than 10 registered users in Youtrack

Client 2020.1.0 does not work from today

Yesterday API version 2020.1.0 worked (the project uses .Net 4.8, so we use this version).
Today I went wrong with an error:

The code:
connection = new BearerTokenConnection ("https: // [some name] .myjetbrains.com / youtrack", "[token]");
connection.CreateIssuesService (). GetIssues (...);

Error:
System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).

How to solve this in a project for .Net 4.8?

PS
We tried a project on .net 5.0 and version YoutTrackSharp 2021.3.1, we get an error:

Unhandled exception. YouTrackSharp.UnauthorizedConnectionException: Could not authenticate. Server did not return expected authentication response. Check the Response property for more details.
at YouTrackSharp.BearerTokenConnection.GetAuthenticatedApiClient ()
at YouTrackSharp.Issues.IssuesService.GetIssues (String filter, Nullable1 skip, Nullable1 take, Boolean wikifyDescription, Boolean wikifyContents)

Implement Administration API's

Switch to the new REST API

Can I ask about the plans for support of the new REST API of YouTrack? Currently we are using the old /rest/... interface, but, if I understand it correctly, JetBrains wants to move to the new /api/... endpoint. This is obviously a substantial change, is there a plan to do it? Or do you have an insight into the state of development of different REST APIs in YouTrack?

Thanks for any information.

Better exception for TimeTrackingService.GetWorkTypesForProject()

I have a program that calls GetWorkTypesForProject on each project in a YouTrack instance. Recently, someone added a project in which time tracking was disabled. YouTrack returns an HTTP 400 response with an error message when I call GetWorkTypesForProject on this project. I'd like to ignore this error, but on the C# side, I just get a HttpRequestException, which is hard to distinguish from other transient/critical HTTP errors like 503.

Expected behavior

Calling GetWorkTypesForProject() when time tracking is disabled throws an informative exception (YouTrackErrorException?)

Actual behavior

Calling GetWorkTypesForProject() when time tracking is disabled throws an HttpRequestException.

Steps to reproduce the behavior

Call TimeTrackingService.GetWorkTypesForProject() on a project in which time tracking is disabled.

2021.3.1 is not working

Tying to get issues from YT:

var connection = new BearerTokenConnection("https://[some].myjetbrains.com/youtrack", "[token]");
onnection.CreateIssuesService().GetIssues("[filter]", take: 1000);

Got error:

Unhandled exception. YouTrackSharp.UnauthorizedConnectionException: Could not authenticate. Server did not return expected authentication response. Check the Response property for more details.
   at YouTrackSharp.BearerTokenConnection.GetAuthenticatedApiClient()
   at YouTrackSharp.Issues.IssuesService.GetIssues(String filter, Nullable`1 skip, Nullable`1 take, Boolean wikifyDescription, Boolean wikifyContents)

How to create a new issue?

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?

UsernamePasswordConnection missing?

Expected behavior

'UsernamePasswordConnection' is referenced in the readme -- but it doesn't appear to exist.

Actual behavior

It's supported in addition to BearerTokenConnection

Steps to reproduce the behavior

Try to use UsernamePasswordConnection.

Implement user administration API's

Provide a strong named version of the library

At the moment it is not possible to depend on this library if you want to strong name your own libraries because YouTrackSharp isn't strong named so it would be good to have a strong named version.

BearerTokenConnection not working

I was trying to add comment using code into particular youtrackitem.
but it is giving 404 error. not sure what is correct api url

var youtrackConnection = new YouTrackSharp.BearerTokenConnection("https://xxxx.myjetbrains.com/youtrack/api/", "token");

                var issuesService = youtrackConnection.CreateIssuesService();

                Task backgroundJobAwaiter = Task.Run(async () =>
                {
                    try
                    {
                        await issuesService.ApplyCommand("Project-1090", command: "Comment", comment: "Test");
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex);
                    }
                });

                backgroundJobAwaiter.Wait();

image

Update to new agile board API

The agile board API has been removed in YouTrack 2018.2. Users on previous versions will still be able to use it, but the API will always return 404 errors on YouTrack 2018.2 and above.

When new API is available, update library to make use of it.

Configure BearerTokenConnection timeout

This might be more of a question than an issue, but is there anyway to set the HttpClient timeout on the BearerTokenConnection object? I've been trying to play around with the object, and using the GetAuthenticatedHttpClient() for setting this property, but I am not having any luck.

Any help would be appreciated.

If this is not supported, I think this would be an extremely convenient feature to add.

issue in custom fields when creating new issue.

hi,
i'v tried several times to create a new issue that contains custom fields but it just won't work.
i even tried to get an issue from the YouTrack and use it's object to create a similar one:

var issueManagement = new IssueManagement(connectionObject);
dynamic issueObject = issueManagement.GetIssue("SPM-191");
issueManagement.CreateIssue(issueObject);

but it also won't add any data to the the custom fields.

UserManagementService .CreateUser replaces '@' with '%40'

Expected behavior

The email address should be valid and as entered with the @ sign

Actual behavior

The email address has the @ sign replaced by %40

Steps to reproduce the behavior

Create new user with an email address and it will "Encode" it.
Same as issue #90 I believe we need to leave the string as is, no encoding since it will be be re-encoded in the body somehow.

Support setting properties on HttpClientHandler

Support setting properties on HttpClientHandler in both BearerTokenConnection and UsernamePasswordConnection. Scenarios could be configuring SSL etc.

An example could be setting the HttpClientHandler's ServerCertificateCustomValidationCallback:

var connection = new BearerTokenConnection(
    "https://ytsharp.myjetbrains.com/youtrack/", 
    "perm:abcdefghijklmn", 
    handler =>
    {
        handler.ServerCertificateCustomValidationCallback =
            (sender, certificate, chain, sslPolicyErrors) => true;
    });

(Note the above is not a secure example as it disables SSL certificate checks!)

Extend properties: add `Created` & `Updated` for `TimeTracking.WorkItem`

We are writing a small program with YouTrackSharp which migrates time tracking entries from YouTrack into an external system. I noticed the JSON returned from /rest/issue/issue id/timetracking/workitem has created and updated fields that reflect when each entry was added or modified. These would be pretty useful for us to avoid reimporting work items we have already seen and to identify updates to old work items, but they are not reflected in the .NET TimeTracking.WorkItem class. Could they be added? Any other missing created or updated fields would also be handy, though I understand that for Issues, they can be retrieved with the GetField() method.

Expected behavior

  • TimeTracking.WorkItem contains Created and Updated members from JSON.

Actual behavior

  • TimeTracking.WorkItem doesn't have Created and Updated members.

Steps to reproduce the behavior

  • Fetch list of WorkItems with TimeTracking.GetWorkItemsForIssue(issue id)

NullReferenceException on Issue Description

When you load Issues and you receive an issue without description (and yes that could happen)
This method will fail when Description is not existent (the same will be for all properties)

public string Description {
get
{
var field = GetField("Description");
return field?.Value.ToString();
}
set => SetField("Description", value);
}

public Field GetField(string fieldName)
{
_fields.TryGetValue(fieldName, out var field); //when this returns false it should not be ignored!!!!
return field;
}

No interfaces of classes in solution - needed for mocking

What we want to do...

is to make unit tests base on YouTrackSharp classes like IssuesService and so I don't want to call server too often. Instead I would rather use interface of the class to mock it in any mocking package so no changes are applied during tests on company's YouTrack.

The problem is...

that there are no interfaces what is pretty dissapointing and there are few ways around to solve this but they are not prefered as they use tricks instead of clear logic.

Solutions...

that we identified (yet to test) are:

  1. Create test project on YouTrack, and add role with access only to this project so it doesn't mess any other projects by accident | | | Problem: connecting to server
  2. Include the code in our repository and create interface ourselves | | | Problem: tracking upstream changes
  3. Create own library | | | Problem: not reliable solution
  4. Mocking HttpClient | | | Problem: too low level, tests dependent on API changes

Action...

that I took was creating those interfaces and commiting to develop branch.

Any help or advise would be apprieciated,
Krzysztof Nowicki

IsMarkDown on case creation not fully implemented

Expected behavior

When using IsMarkDown = false it should create a case without the Markdown option ( YouTrack Wiki ). The Querystring sent to YT should show markdown=false.

Actual behavior

Nothing is appended to the QueryString when using IsMarkDown = false. ( only appended when IsMarkDown = true )

Steps to reproduce the behavior

Create an issue and use IsMarkDown = false, the querystring is not appeneded and the Case is created with the default value to MarkDown.

Potential fix on or around: "if (issue.IsMarkdown)" on line 97 of IssueService.cs

Field names ignore case: why?

The current implementation parses JSON from server while ignoring the case of field names. This behaviour is AFAIK implemented in file Issues/Issue.cs on line 22:

private readonly IDictionary<string, Field> _fields = new Dictionary<string, Field>(StringComparer.OrdinalIgnoreCase);

I am not sure why we have this behaviour -- JSON is case-sensitive and YouTrack can have two different fields that only differ in case (in my case it was fields Sprint and sprint). I was able to fix it by simply changing the comparer to StringComparer.Ordinal. I would be very happy to submit this simple change as pull request, or am I missing something?

Thank you.

UserManagementService .CreateUser replaces ' ' with '%20'

Expected behavior

There is still an issue in POST/PUT requests. It is linked to the #89.

Actual behavior

Currentlu it replaces spaces in string with the space escape code '%20'. I guess the reason is escaping strings for FromData requests. In case of POST/PUT data could be sent as is, because of sending in request body, but not in the URL

Steps to reproduce the behavior

Request-URI Too Long

Thr following code:

BearerTokenConnection ytConnection = new BearerTokenConnection(
 "https://youtrack.XXX.com/",
 "perm:...");

Issue issue = new Issue
{
    Description = description.ToString(),
    Summary = "Summary",
};

IIssuesService issuesService = ytConnection.CreateIssuesService();

string id = await issuesService.CreateIssue("XXX", issue);

Results in a System.Net.Http.HttpRequestException with the message
"Response status code does not indicate success: 414 (Request-URI Too Long)."

What am I doing wrong here?

Define content-type header in IssuesService.AttachFileToIssue

Using YouTrackSharp 2019.1.0.0

Expected behavior

  • Using IssueService.AttachFileToIssue with an XLSX file.
  • Document is uploaded.
  • When downloading the file from Youtrack, it's expected to be able to have the correct content type header

Actual behavior

  • File is served as a ZIP file.

Possible fix ?

Allow uploader to specify content type in the MultipartFormDataContent object in the AttachFileToIssue metehod

Add wikifyDescription param to IssuesService.GetIssues()

We are trying to show user-facing descriptions of the issues returned by a specific query, however some issues contain wiki markup, which obscures the content of the description. It would be great if we could use wikifyDescription=true to fetch the description as HTML, so we could use an HTML parser to get a user-facing description of each issue.

Expected behavior

  • IssuesService.GetIssues() accepts the wikifyDescription parameter, like IssuesService.GetIssuesInProject() and the REST API.

Actual behavior

  • IssuesService.GetIssues() does not accept a wikifyDescription parameter.

Steps to reproduce the behavior

  • Call IssuesService.GetIssues("", wikifyDescription: true)

Is support for Markdown in text custom fields on the roadmap?

Hello,

We have a Release Notes custom text field in YouTrack. We pull it via API to display in the external release notes generator app.

The issue we came across is that there's no way to get markdown text converted to HTML using YouTrackSharp client.

YouTrack API itself returns markdown text transformed to HTML when requested. For a example a request like this:
http://youtrackurl/api/issues/AB-2420?fields=$type,id,summary,customFields($type,id,projectCustomField($type,id,field($type,id,name)),value($type,avatarUrl,buildLink,color(id),fullName,id,isResolved,localizedName,login,minutes,name,presentation,text,markdownText))
returns markdownText property:

        {
            "projectCustomField": {
                "field": {
                    "name": "Release Notes",
                    "id": "30-39",
                    "$type": "CustomField"
                },
                "id": "201-10",
                "$type": "TextProjectCustomField"
            },
            "value": {
                "id": "text",
                "text": "n/a - internal\n**testing markdown**\nList:\n- item 1\n- item 2",
                "markdownText": "<div class=\"wiki text common-markdown\"><p>n/a - internal<br/><strong>testing markdown</strong><br/>List:</p>\n<ul class=\"wiki-list0\">\n<li>item 1</li>\n<li>item 2</li>\n</ul>\n</div>",
                "$type": "TextFieldValue"
            },
            "id": "201-10",
            "$type": "TextIssueCustomField"
        }

I tried to use a few other markdown libraries to manually convert markdown to HTML, but they produce a different result than YouTrack.

Please let me know if exposing markdownText property is in the roadmap.

Alex

Wrong Json Conversion in UnixDateTimeOffsetConverter

In https://confluence.jetbrains.com/display/YTD4/Timestamps+in+REST+API

For any timestamp in REST API, YouTrack uses Java timestamp format: The number of milliseconds

But in
https://github.com/JetBrains/YouTrackSharp/blob/master/src/YouTrackSharp/Json/UnixDateTimeOffsetConverter.cs
in method WriteJson I see ".ToUnixTimeSeconds()"
and because of this when I do
timeTrackingService.CreateWorkItemForIssue("MA-2633", new WorkItem(new DateTime(2017, 1, 1), TimeSpan.FromHours(0.5), ""))
then I have a result with date 18 Jan 1970 in YouTrack

In F# project: System.Net.Http manifest definition does not match the assembly reference

I want to use YoutrackSharp in my F# application. When I install the YoutrackSharp Nuget package and run my application, I get the following runtime error:

System.IO.FileLoadException:
'The File or Assembly "System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" or one of its dependencies could not be found.
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

I use .F# 4.1, NET Framework 4.7 and Visual Studio 2017 (15.3.5). The same exception occurs with other .NET frameworks (I tested 4.6.1)

Steps to reproduce:

  1. Create a new "F# Console Application" project in Visual Studio (with .NET Framework 4.7),.
  2. Install YoutrackSharp via the Nuget package manager (I installed v3.1.0)
  3. Make some API call somewhere in the program
  4. Build (no error)
  5. Run (API call fails with FileLoadException)

When I do the same in C#, everything works. Is this some kind of version conflict with a dependency from FSharp.Core? How could I debug this?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.