0

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

    function send_to_jira($url, $data) {

    $username = '[email protected]';
    $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);

2 Answers 2

0

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. Alternatively, you can also use the issue/<issue>/assignee endpoint. 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.

Sign up to request clarification or add additional context in comments.

Comments

0

Instead of

   ("name" = "newusername")

use

("accountId" = "5b109f2e9xxxb51b54dc274d")   

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.