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 = '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
. 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 .
Instead of
("name" = "newusername")
use
("accountId" = "5b109f2e9xxxb51b54dc274d")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.