簡體   English   中英

使用php和JIRA SOAP API添加注釋以發布問題

[英]Add comment to issue using php and JIRA SOAP API

如何使用PHP和Jura的SOAP API在JIRA問題中添加評論? 我已連接並測試了該連接以檢索一個現有問題,所有連接運行良好,但是當我嘗試使用addComment方法時,它將返回以下內容:

致命錯誤:未捕獲的SoapFault異常:[soapenv:Server.userException] org.xml.sax.SAXException:錯誤的類型(類java.util.HashMap-> com.atlassian.jira.rpc.soap.beans.RemoteComment類) home / a7348186 / public_html / jira.php:46堆棧跟蹤:
#0 /home/a7348186/public_html/jira.php(46):SoapClient-> __ call('addComment',Array)
#1 /home/a7348186/public_html/jira.php(46):SoapClient-> addComment('16VGN3ohoo','NTP-> 29',Array)
#2 {main}在第46行的/home/a7348186/public_html/jira.php中拋出

這是我的代碼:

<?php
$emailplain = $_REQUEST['plain'];
$emailsubject = $_REQUEST['subject'];
$inputkey = $_REQUEST['key'];
$inputsumm = $_REQUEST['summ'];
$client = new SoapClient(NULL,
    array(
        "location" => "https://server.com/rpc/soap/jirasoapservice-v2?wsdl",
        "uri"      => "urn:xmethods-delayed-quotes",
        "style"    => SOAP_RPC,
        "use"      => SOAP_ENCODED
        ));
$token = $client->login("user", "pass");
$issueId = $inputkey;
$issue = $client->getIssue($token, $issueId);
echo("assignee:".$issue->assignee);
echo(" created:".$issue->created);
echo(" summary:".$issue->summary);
echo(" issueid:".$issue->key);
print $inputsumm;
$stringsummary = $issue->summary;

$string = $issue->summary;
$emailsubjectregexp = preg_replace('/[a-zA-Z]+/', '', $inputsumm);
$stringsumm = ('summary ~ "' . $emailsubjectregexp . '"');
$jqlstring = $stringsumm;

$searchjql = $client->getIssuesFromJqlSearch($token, $jqlstring, 100);
function printArray ($array, $devolver = false) {
    $stringa = '<pre>' . print_r($array, true) . '</pre>';
    if ($devolver) return $stringa;
    else echo $stringa;
}
printArray($searchjql);
print_r ($searchjql);
$key = $searchjql[0]->key;
echo $key;
$client->addComment($token, $key, array('body' => 'your comment'));
?>

如果您注意到,最后一行包含執行我想要的代碼,但是沒有運氣。 大家有什么想法嗎?

更改創建Soap客戶端對象的方式,請更改:

$client = new SoapClient(NULL,
    array(
        "location" => "https://server.com/rpc/soap/jirasoapservice-v2?wsdl",
        "uri"      => "urn:xmethods-delayed-quotes",
        "style"    => SOAP_RPC,
        "use"      => SOAP_ENCODED
        ));

至:

$client = new SoapClient("https://jira.watchitoo.com/rpc/soap/jirasoapservice-v2?wsdl");

這應該工作。

全加注釋代碼:

$issueKey = "key-123";
$username= "JiraUser";
$password= "JiraPassword";
$jiraAddress = "https://your.jira.com/rpc/soap/jirasoapservice-v2?wsdl";
$myComment = "your comment";

$soapClient = new SoapClient($jiraAddress);
$token = $soapClient->login($username, $password);
$soapClient->addComment($token, $issueKey, array('body' => $myComment));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM