通过REST API - PHP在选项卡式屏幕上创建JIRA问题

时间:2016-07-14 12:57:56

标签: php rest jira

我有以下带有TABS的JIRA屏幕,我想通过REST API在" Resquestor Details选项卡上创建一个vISSUE。enter image description here"

现在我有以下代码,我不知道在哪里指定选项卡名称。

 public function createTestData($firstName, $surname, $userID, $email, $testPortfolio, $projectName,$projectID,
                            $newSystem, $newProduct, $requirementsFunction, $evinronment, $dueDate, $region,
                            $summary, $description)
{


    if ($this->finduser($email) < 1)
        {
            $json = Array ( "fields" => Array (
                                                "project" => Array
                                                    ( "id" => 20207 ),
                                                        "summary" => "$summary",
                                                        "description"=>"$description",
                                                        "issuetype" => Array ( "name" => "Test Data" ),
                                                        "customfield_14421" => "$firstName",
                                                        "customfield_15026" =>"$lastName",
                                                        "customfield_14490" =>"$userID",
                                                        "customfield_14415" =>"$email",
                                                        "customfield_156681" =>Array ("value" => "$testPortfolio"),
                                                        "customfield_12103" =>"$projectName",
                                                        "customfield_14236" =>"$projectID",
                                                        "customfield_14430" =>"$newSystem",
                                                        "customfield_15672" =>"$newProduct",
                                                        "customfield_15673" =>Array ("value" => "$requirementsFunction"),   
                                                        "customfield_15685" =>Array ( "value" => "$environment"),
                                                        "customfield_15700" =>"$region",                                           
                                                        "reporter" =>Array ("name" => "API"  )
                                                )
                        );
        }


    return $json;
}

我看了Documentation,但我真的没有看到它或在任何地方看到它。

我收到此错误:

  

无法设定。它不在适当的屏幕上,或未知。适用于所有领域   但字段是正确的问题类型和权限也是正确的。

1 个答案:

答案 0 :(得分:0)

如果您使用JIRA Rest API创建问题,即。 POST /rest/api/2/issue,然后您无需考虑在JIRA中查看问题时显示的选项卡。您只需在发布到JIRA的json中设置所有需要的字段和自定义字段。

您没有列出发送给JIRA的确切内容,因此我不完全确定您使用的是哪种REST资源。

您提到的错误表示您正在尝试设置&#34;创建屏幕&#34;为您的项目。您可以使用GET /rest/api/2/issue/createmeta资源对此进行验证。可能它的输出不会列出您尝试设置的所有字段。

要纠正此问题,您必须验证项目使用的屏幕方案,并确保&#34;创建屏幕&#34;与该方案相关联的列出了必要的字段。相关的JIRA文档可用here

作为旁注:您在查看问题时看到的标签在&#34;查看问题&#34;中定义。项目屏幕方案的屏幕。