dapplo / Dapplo.Jira

This is a simple REST based JIRA client, written for Greenshot, by using Dapplo.HttpExtension
MIT License
35 stars 14 forks source link

JiraConfig.ExpandGetIssue #53

Closed toertchn closed 3 years ago

toertchn commented 3 years ago

Hello,

when I try to get an issue with the renderedFields I got a JsonReaderException exception:

JiraConfig.ExpandGetIssue = new[] { "renderedFields" };
var issue = await Client.Issue.GetAsync(TestIssueKey);

Nachricht: Newtonsoft.Json.JsonReaderException : Could not convert string to DateTimeOffset: Gestern 1:58 PM. Path 'renderedFields.lastViewed', line 1, position 20629. Stapelüberwachung: JsonReader.ReadDateTimeOffsetString(String s) JsonTextReader.FinishReadQuotedStringValue(ReadType readType) JsonTextReader.ReadAsDateTimeOffset()

Lakritzator commented 3 years ago

Hi,

I don't have time right now to look at it in details, but it sounds like you are forcing Jira to return only the RENDERED values which normally would be presented in the UI. This is not something my library can process, especially not date descriptions in any language (this case German) The fix would be not to use "renderedFields".

Any reason why you would do this?

Best wishes, Robin

toertchn commented 3 years ago

Hi, using "renderedFields" correctly returns the fields and renderedFields. The problem seems to be in the values. The rendered values should be left as strings.

"fields": {
"lastViewed":"2020-12-14T09:22:40.114+0100",
"resolutiondate":"2020-12-13T13:56:48.650+0100",
"updated":"2020-12-13T13:58:51.571+0100",
"created":"2020-12-13T13:36:07.016+0100",
}

"renderedFields": {
"lastViewed":"Vor 6 Stunden",
"resolutiondate":"Gestern 1:56 PM",
"updated":"Gestern 1:58 PM",
"created":"Gestern 1:36 PM",
}

Atlassian.sdk won't support renderedFields. This project has the ability but should not be used?

I need the description in html format. So the best way is to grab it directly from the isses. The other way is to search for a Jira markup to HTML converter.

Lakritzator commented 3 years ago

I'll need to check it out, thanks for the additional information to understand the context. Just wanted to quickly reach out, it's not about "should not be used" but was my first thought.

Yes the rendered values should not be interpreted, so this might be the issue. Okay, just so you know: I work, have a kid, we are in a lockdown and my laptop is kinda broken, if it's something simple I might be able to fix this by the end of the weekend. If not, I can't give an estimate.

Lakritzator commented 3 years ago

Already had a bit of time, as it plainly interested me... I need to recreate all the types (IssueFields and everything below), with types which can contain a rendered content. (so e.g. the date fields now need to also be able to contain a string)

This is doable, but will take some hours... which I first need to find. I'll keep you informed when it works.

Lakritzator commented 3 years ago

I went ahead and fixed all things that were desturbing the retrieval of renderedFields, so in my somewhat limited test it seems to work. I also checked what fields might cause issues, and during this I found: https://jira.atlassian.com/browse/JRASERVER-65922 In a nutshell, JIRA doesn't deliver all fields when requesting the renderedFields.

So there are limitations to what I can do, many values are plainly "null". I hope these limitations don't bother you.

The updated version 1.1.21 will be available shortly, let me know if this works.

Lakritzator commented 3 years ago

@toertchn please give me feedback if my changes work for you.

toertchn commented 3 years ago

Hello Robin,

thank you for the quick fix - work's like a charm ;-)

Lakritzator commented 3 years ago

I'm happy it works for you, let me know if I can help any more. And remind, most restictions are with Atlassian (https://jira.atlassian.com/browse/JRASERVER-65922)

And btw.. thanks ❤️ I ordered a Raspberry pi 4 (with 8GB) which I can use to have a local instance of JIRA for some of the weird border cases, where I don't want to play around with the JIRA for Greenshot (you know that this project got started due to the fact that I needed a Jira library to connect Greenshot to Jira?)

Closing this issue.