'Atlassian.Net SDK / Jira - Getting available fields when creating new issue

I'm currently working on a connection to a cloud test environment (xyz.atlassian.net). So far I managed to authenticate a user but when I try to do some "silly" stuff like setting a priority on a Task issue the API call will fail with a 400 Bad request. I understand that the field Priority is not available for issue type Task but indeed for the type Bug.

My question is how would I know which fields can be set before I create the issue? I found some help in the REST reference where they say one could evaluate the result of: /rest/api/2/issue/createmeta?expand=projects.issuetypes.fields

That indeed gives me a JSON containing a lot of data regarding issue types and their fields but I'm having a hard time parsing that. It looked like the records there would match the definition of IssueFieldEditMetadata but the serializer just can't seem to create an instance from the JSON. Since there's a central Jira class within the root namespace with several service getters I'd expect to see some service that would provide something like GetFieldsForIssueType(string issueTypeKey) but I haven't found anything similar.

Am I doing it the wrong way? I'm pretty new to REST and Jira in general, so please correct me if I messed things up in this post. Always happy to learn ;-)

Best, Killian



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source