Comments (12)
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.
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.
Yes, will take a bit of time, sorry for the hiccup :)
from youtracksharp.
After e-mail discussion this got flagged as a bug in YouTrack itself. Will proceed with 2019. release of this library.
from youtracksharp.
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.
@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.
@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:
from youtracksharp.
That could be a data problem indeed. Do you see the same issue with other queries or only this one?
from youtracksharp.
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.
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.
Regarding the error 500, can you email me the query, project name and instance name?
from youtracksharp.
thank you for taking a look - i've sent it.
from youtracksharp.
Related Issues (20)
- 2021.3.1 is not working HOT 7
- 2021.3.1 Не могу получить поле типа "StateMachineIssueCustomField" HOT 2
- Package YouTrackSharp 2021.3.1 is not compatible with net48 HOT 5
- Custom fields problem HOT 3
- Error casting types HOT 6
- Adding a comment HOT 1
- Calling BearerTokenConnection.GetAuthenticatedApiClient hangs HOT 2
- Token is granted for [YouTrack] and can't be used for 0-0-0-0-0 HOT 3
- GetChangeHistory() NullReferenceException in JArray conversion for Change with ProjectActivityItem changed from Null to Something HOT 2
- AgilesGetAsync does not correctly populate issue custom fields
- CreateWorkItemForIssue fails with Bad Request error
- How to get git commit text for issue id HOT 1
- SetField value doesn't update the actual value. HOT 1
- StateMachineIssueCustomField deserialization failing HOT 1
- Cant return customFields HOT 3
- How to create a comment with a file HOT 1
- CreateIssue fails with 404 in AdminUsersMeDraftsAsync HOT 6
- Custom field value is both null and not-null (?) HOT 1
- Unclear documentation / returned errors regarding required authentication scopes
- Latest build wrong project initialization HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from youtracksharp.