我正在使用以下代码更新 JIRA 中的问题,但无法诊断错误。我得到的错误如下:
HTTP 状态 415 - Unsupported Media Type type 状态报告消息 Unsupported Media Type
我写的代码如下:
$resource_array['api_name'] = 'issue/SPC-60';
$resource_array['fields'] = array (
'summary' => 'CLONE - Testing label stuff',
'assignee' =>
array (
'emailAddress' => 'avinashk.dubey@gmail.com',
),
'customfield_10649' =>
array (
'id' => '10668',
),
'customfield_10616' => 'This is observation'
);
$data = putJiraAPI($resource_array);
print_r($data);
////////////////////////////////////////////
function putJiraAPI($resource_array)
{
$api_name = $resource_array['api_name'];
unset($resource_array['api_name']);
$result = put_to($api_name, $resource_array);
if(is_array($result))
{
return $result;
}
else
{
return "error while getting data using ".BASE_URL.API_URL.$resource_string;
}
}
function put_to($api_name, $resource_array)
{
$jdata = json_encode($resource_array);
print_r($jdata);
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_URL => BASE_URL . API_URL . $api_name,
CURLOPT_USERPWD => USER_NAME . ':' . PASSWORD,
CURLOPT_POSTFIELDS => $jdata,
CURLOPT_HTTPHECURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
CURLOPT_RETURNTRANSFER => true
));
echo BASE_URL . API_URL . $api_name;
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result,true);
}