Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to return the order of fields in create meta on issue screens #148

Open
betterphp opened this issue Oct 12, 2016 · 1 comment

Comments

@betterphp
Copy link
Contributor

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.

@aik099
Copy link
Collaborator

aik099 commented Oct 12, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants