简体   繁体   English

通过 REST API (php) 在 Jira 中的受让人

[英]Assignee in Jira via REST API (php)

I want to assignee issue to another person.我想将受让人问题交给另一个人。

I have the code, but it doesn't work.我有代码,但它不起作用。 Why?为什么? Who can help me?谁能帮我?

May some parameter is wrong?可能某个参数有误?

If I enter to the JIRA via this login and pass I can change assigneer如果我通过此登录名进入 JIRA 并通过,我可以更改分配人

    function send_to_jira($url, $data) {

    $username = 'bot@user.name';
    $password = 'bot_password';

    $curl = curl_init();
    $headers = array(
        'Accept: application/json',
        'Content-Type: application/json'
    );
    curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLINFO_HEADER_OUT, true);

    $result = curl_exec($curl);
    $info = curl_getinfo($curl);
    curl_close($curl);
    return $result;
}

        $data = array(
            "fileds" => array(
                "assignee" => array("name" => "newusername")
            ),
        );
        $url = 'https://site/rest/api/2/issue/ISSUE';
        $result = send_to_jira($url, $data);

If you have just copied your code, then there is a typo in the $data object you're sending: you have to write fields instead of fileds .如果您刚刚复制了您的代码,那么您发送的$data对象中有一个错字:您必须编写fields而不是fileds Alternatively, you can also use the issue/<issue>/assignee endpoint.或者,您也可以使用issue/<issue>/assignee端点。 See docs for server or cloud .请参阅服务器云的文档。

As an addition, if you are making this call to a Jira Cloud REST API, please take care about the deprecation notices regarding basic authentication and usernames .另外,如果您要调用 Jira Cloud REST API,请注意有关基本身份验证用户名的弃用通知。

Instead of代替

   ("name" = "newusername")

use

("accountId" = "5b109f2e9xxxb51b54dc274d")   

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM