使用 Jira API 将客户指定为报告者会产生问题吗?

Creating the issue with assigning the customer as the reporter with Jira API?

如果新客户不存在,我想创建新客户并创建新问题设置 此客户作为报告者 在 PHP 中使用 Jira API。

我使用 API 'servicedeskapi/customer' 和 POST 字段 'fullName' 和 'email' 创建新客户,然后我使用 API '[ 创建新问题=32=]' 带有参数 'fullName' 和参数 'reporter' 的 'email'。

我正在尝试这样做:

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_USERPWD, 'user:password');

$postvars = array('fields' => array('project' => array('key' => 'AP'), 'summary' => $body, 'description' => $body, 'reporter' => null));

$postvars['fields']['issuetype'] = array("id" => '10108');
$postvars['fields']['reporter']['fullName'] = $name; //POST field of customer's name to set customer as the reporter of new issue
$postvars['fields']['reporter']['email'] = $email; //POST field of customer's email address to set customer as the reporter of new issue

curl_setopt($ch, CURLOPT_URL, 'https://jira-address/rest/servicedeskapi/customer');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json', 'X-ExperimentalApi: opt-in'));
curl_setopt($ch, CURLOPT_POSTFIELDS,
json_encode(array('fullName' => $reporterName, 'email' => $email))); //POST fields for creating new customer
$r = curl_exec($ch); //sending request for creating new customer
echo json_encode(json_decode($r), JSON_PRETTY_PRINT); //printing response of request for creating new customer

curl_setopt($ch, CURLOPT_URL, 'https://jira-address/rest/api/2/issue/');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postvars));
$r = curl_exec($ch); //sending request for creating new issue
echo json_encode($postvars, JSON_PRETTY_PRINT); //printing POST fields of the request of creating new issue
echo json_encode(json_decode($r), JSON_PRETTY_PRINT); //printing the response of the request for creating new issue

如果客户不存在,响应为:

{
    "name": "kamilszmit2@live.com",
    "key": "kamilszmit2@live.com",
    "emailAddress": "kamilszmit2@live.com",
    "displayName": "kamilszmit2",
    "active": true,
    "timeZone": "Europe\/Warsaw",
    "_links": {
        "jiraRest": "https:\/\/jira-address\/rest\/api\/2\/user?username=kamilszmit2%40live.com",
        "avatarUrls": {
            "48x48": "https:\/\/jira-address\/secure\/useravatar?avatarId=10122",
            "24x24": "https:\/\/jira-address\/secure\/useravatar?size=small&avatarId=10122",
            "16x16": "https:\/\/jira-address\/secure\/useravatar?size=xsmall&avatarId=10122",
            "32x32": "https:\/\/jira-address\/secure\/useravatar?size=medium&avatarId=10122"
        },
        "self": "https:\/\/jira-address\/rest\/api\/2\/user?username=kamilszmit2%40live.com"
    }
}{
    "fields": {
        "project": {
            "key": "AP"
        },
        "summary": "test",
        "description": "test",
        "reporter": {
            "fullName": "kamilszmit2",
            "email": "kamilszmit2@live.com"
        },
        "issuetype": {
            "id": "10108"
        }
    }
}{
    "id": "11187",
    "key": "AP-351",
    "self": "https:\/\/jira-address\/rest\/api\/2\/issue\/11187"
} 

已创建客户和问题,但客户未设置为问题的报告者。如果 customer 已经存在,并且只使用参数“reporter”的参数“fullName”或“email”,也会出现同样的问题。

我做错了什么? 如何创建以客户为报告者的 Jira 问题?你能帮我吗?

通过 REST,我设法使用 name 参数而不是 fullname 来设置报告器。

"fields": {
        "project": {
            "key": "AP"
        },
        "summary": "test",
        "description": "test",
        "reporter": {
            "name": "kamilszmit2"
        },
        "issuetype": {
            "id": "10108"
        }

我要检查的其他事项:

  • 报告者字段已添加到创建问题屏幕
  • 这些调用的凭据 运行 具有 修改报告者 项目权限(如果他们没有,您将 运行 进入 405 错误 此权限)