Add method to return the order of fields in create meta on issue screens
The createmeta endpoint does not return fields in the order they should appear on issue create screens. Based on this question it sounds like a deliberate thing, cynically thinking to try and make more users need JIRA accounts.
The actual create screen in JIRA makes a call to a JSON endpoint when you switch project or issue type in the dropdown so that can be used to get the field order (as well as a heap of other information)
How would you feel about adding a method that uses a URL not in the API docs?
Proof of concept code snippet:
$url = 'https://' . config::JIRA_HOST . '/secure/QuickCreateIssue!default.jspa?decorator=none';
$post = http_build_query([
'pid' => $project['id'],
'issuetype' => $issue_type,
]);
$data = @file_get_contents($url, false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => implode("\r\n", [
'Host: ' . config::JIRA_HOST,
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
'Content-Length: ' . strlen($post),
'Authorization: Basic ' . base64_encode(config::JIRA_USER . ':' . config::JIRA_PASS),
]),
'content' => $post,
],
]));
if ($data === false){
return [];
}
$data = json_decode($data);
$fields = [];
foreach ($data->fields as $field){
$fields[] = $field->id;
}
Annoyingly pid is the project ID and not the text key so it has to be done with two requests.
Thank you for a research you've made, but the proposed solution looks too fragile, because:
- this isn't officially supported way by JIRA
- the URL for a call isn't guaranteed to exist
- format of response on that URL isn't guaranteed to be the same
The JIRA UI replication does sound like a very specific thing (people don't do this every day), so for your project you can make such call, but I won't be accepting it into the library.