JetBrains / YouTrackSharp

.NET Standard 2.0 Library to access YouTrack API.
https://www.jetbrains.com/youtrack
Apache License 2.0
135 stars 105 forks source link

Custom fields problem #111

Closed gh-pp closed 3 years ago

gh-pp commented 3 years ago

Expected behavior

Custom fields declared in code should be sended to the yt api. Version 2021.3.3

Actual behavior

Custom fields declared in code are not transposed to request - code example:

var newIssue = new Issue() { Summary = "SM - TEST", Description = "" };
newIssue.SetField("SysId", monitoring.Id);

Is transposed to request without any custom fields data (via fiddler):

{"$type":"Issue","project":{"$type":"Project","id":"0-41"},"summary":"SM - TEST","usesMarkdown":false}

Steps to reproduce the behavior

Showed above

gh-pp commented 3 years ago

I figured out that in code there is customfields implementation connected with commands - it works but only in case where custom fields are not required. In youtrack api docs (https://www.jetbrains.com/help/youtrack/devportal/api-howto-create-issue-with-fields.html#step-by-step) there is example to send it in one request.


"project":{"id":"0-0"},
"summary":"REST API lets you create issues!",
"description":"Let'\''s create a new issue using YouTrack'\''s REST API.",
"customFields":[
{ "name":"Priority","$type":"SingleEnumIssueCustomField","value":{"name":"Show-stopper"}},
{ "name": "Assignee","$type": "SingleUserIssueCustomField","value": {"login":"jane.doe"}}
]
}
rekolobov commented 3 years ago

Thanks for the report!

The old code was based on commands as well, but since https://youtrack.jetbrains.com/issue/JT-64160 was fixed in 2021.3, I'd have to change this logic. Unfortunately, I was mistakenly using YT 2021.2 for most of the tests and thus overlooked the problem.

It might take a couple of days, since I don't remember atm whether specifying exact value for $type is required -- if so, it would take a bit more effort to test it properly

rekolobov commented 3 years ago

Released 2021.3.4 and published to NuGet