Closed bschaeublin closed 5 years ago
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.
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.
Yes, will take a bit of time, sorry for the hiccup :)
@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
@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:
That could be a data problem indeed. Do you see the same issue with other queries or only this one?
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.
Paging seems to work, just added a unit test testing this explicitly: https://github.com/JetBrains/YouTrackSharp/commit/5116ca89c3362b51359c7764c6479467cb5bb0c8
Could you perhaps reach out to YouTrack support to troubleshoot that 500 error?
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.
Regarding the error 500, can you email me the query, project name and instance name?
thank you for taking a look - i've sent it.
After e-mail discussion this got flagged as a bug in YouTrack itself. Will proceed with 2019. release of this library.
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:
So it seems there were multiple breaking changes in the new API Version, which this library does not support at this point.