Coder Social home page Coder Social logo

Comments (12)

bschaeublin avatar bschaeublin commented on September 3, 2024 2

I had some time (holidays!) and managed to find out some stuff.

I edited your unit test to connect to our youtrack instance and changed the test a bit:

            [Fact]
            public async Task Valid_Connection_Page_Issues()
            {
                // Arrange
                var url = "an url";
                var token = "a token";

                var con = new BearerTokenConnection(url, token);

                var service = con.CreateIssuesService();

                // Act
                var totalResultsCount = 0;

                var skip = 0;
                while (skip < 1000)
                {
                    var result = await service.GetIssues("resolved date: 2018-02 .. 2019-01", skip, take: 100);
                    if (result?.Count > 0)
                    {
                        totalResultsCount += result.Count;
                    }
                    else
                    {
                        break;
                    }

                    skip += 100;
                }

                // Assert
                Assert.True(totalResultsCount > 100);

            }

The test failed, so i edited the IssueService.Querying.cs GetIssues Method to take the new api andpoint /api/issues instead of /rest/issue and the the test succeeded.

I compared the api results and discovered that the new api endpoint does not return all fields per default. So maybe it has to do with one field.

I reverted my changes and modified the GetIssue Method to return just the fields that i want.
Field by field I found out it is the field "links" which shows the relation of the ticket. Maybe it is a ticket with circular references that causes the internal server error?

I was wondering if the new api could handle it, and added the field in the request (see following sample) and rerun the unit test.
The test succeeded.

 public async Task<ICollection<Issue>> GetIssuesv20191(string filter = null, int? skip = null, int? take = null, bool wikifyDescription = false)
        {
            var queryString = new List<string>(5);
            if (!string.IsNullOrEmpty(filter))
            {
                queryString.Add($"filter={WebUtility.UrlEncode(filter)}");
            }
            if (skip.HasValue)
            {
                queryString.Add($"after={skip}");
            }
            if (take.HasValue)
            {
                queryString.Add($"max={take}");
            }

            queryString.Add("fields=id,links");
            queryString.Add($"wikifyDescription={wikifyDescription}");

            var query = string.Join("&", queryString);

            var client = await _connection.GetAuthenticatedHttpClient();
            var response = await client.GetAsync($"api/issues?{query}");

            if (response.StatusCode == HttpStatusCode.NotFound)
            {
                return null;
            }

            response.EnsureSuccessStatusCode();

            var resultStr = await response.Content.ReadAsStringAsync();
            var issues = JsonConvert.DeserializeObject<Issue[]>(resultStr);
            return issues;
        }

The new api is not documented the way the old one was - so I have no idea how we get the new API endpoint to return all fields per default. If this would be possible we would have to change the endpoints from "/rest/issue" to "/api/issues" and change all the query parameters accordingly.

What do you think?

And some thoughts at the end:
A pitty, that existing api implementations are all broken now (for example my custom azure logic app connector), an api versioning would have been the preffered way to refactor an api.

from youtracksharp.

maartenba avatar maartenba commented on September 3, 2024 1

An API overhaul has been done in 2019.1. We are looking at working on a new version of YouTrackSharp, for now 2019.1 is unfortunately not supported.

from youtracksharp.

maartenba avatar maartenba commented on September 3, 2024 1

Yes, will take a bit of time, sorry for the hiccup :)

from youtracksharp.

maartenba avatar maartenba commented on September 3, 2024 1

After e-mail discussion this got flagged as a bug in YouTrack itself. Will proceed with 2019. release of this library.

from youtracksharp.

bschaeublin avatar bschaeublin commented on September 3, 2024

Thank you for your reply. I guess this will take some time?

I'm using 3 Endpoints so far, so I'll then create a light-weight client on my own until an official new version will be released.

from youtracksharp.

maartenba avatar maartenba commented on September 3, 2024

@bschaeublin Would you mind trying with the 2019.1 prerelease version from NuGet?
https://www.nuget.org/packages/YouTrackSharp/2019.1.0-alpha-00003

Install-Package YouTrackSharp -Version 2019.1.0-alpha-00003

from youtracksharp.

bschaeublin avatar bschaeublin commented on September 3, 2024

@maartenba Thank you! At least GetIssueCount does work now.
But i still get some problems when I call GetIssues with a specific query, which worked before.
I think i can delimit it to the date range search. Maybe it is a data problem too, as the Internal Server Error occurs on page 3, when paging with 100.

Please see attached screenshot:
image

from youtracksharp.

maartenba avatar maartenba commented on September 3, 2024

That could be a data problem indeed. Do you see the same issue with other queries or only this one?

from youtracksharp.

bschaeublin avatar bschaeublin commented on September 3, 2024

I've managed to successfully run a query on a small test project. Is there a way to provide some more details on the 500 Issue? Can you reproduce the issue with any querys on bigger projects and paging through?

We're using it as SAAS, but I don't think i've enough privileges to get some logs.

from youtracksharp.

maartenba avatar maartenba commented on September 3, 2024

Paging seems to work, just added a unit test testing this explicitly: 5116ca8

Could you perhaps reach out to YouTrack support to troubleshoot that 500 error?

from youtracksharp.

maartenba avatar maartenba commented on September 3, 2024

Regarding the error 500, can you email me the query, project name and instance name?

from youtracksharp.

bschaeublin avatar bschaeublin commented on September 3, 2024

thank you for taking a look - i've sent it.

from youtracksharp.

Related Issues (20)

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.