Jira PHP SOAP updateissue doesnt work
I tried updating component for issue in Jira using SOAP in PHP, it didnt throw any exception, it returned isuue but component was never updated.
Any ideas?
here is my sample code:
$myIssue="";
$myIssue['components'][] = array("id" => "10769", "name" => "component name");
$soap->updateIssue($auth,"ISSUEKEY", $myIssue);
It just returns issue without any change to component.
This is what is sent out of php when i print that variable :
Array ( [components] => Array ( [0] => Array ( [id] => 10769 [name] => component name 开发者_JAVA百科 ) ) )
I am not a PHP developer, but I think that this code:
arrayToObject(array("id" => "10769", "name" => "component name")
Results in this:
{
id: '10769',
name: 'component name'
}
Am I right?
Which would result in this being sent to JIRA as the RemoteFieldValue Array:
{components: [{
id: '10769',
name: 'component name'
}]}
If so, I do not think that is what jira is expecting. I believe it is expecting:
[
{id: 'components',value:'component name'}
]
Remember that Java does not have associative arrays. So the construct $myIssue['components'][] doesn't mean anything to Java. Java also does not support multi-dimensional arrays of different types.
Update:
Try this (Or something like it, my code is not tested):
<?php
class RemoteFieldValue {
var $id;
var $values = array();
function __construct($idIn, $valuesIn) {
$this->id = $idIn;
$this->values = $valuesIn;
}
}
$rfv = new RemoteFieldValue('components', array("id" =>"componentid_goes_here"));
$rfvArray = array($rfv);
$soap->updateIssue($auth,"ISSUEKEY", $rfvArray);
?>
When I put together a JIRA service in ColdFusion I implemented each JIRA object (User, Issue, RemoteFieldValue, etc) as a ColdFusion object. I suspect you could also do it with associative arrays and arrays, but I find this cleaner and it makes it easier to adapt to what the JIRA SOAP service expects.
The easiest way to update a field is to pass the object
First define the class (generated from the WSDL)
class RemoteFieldValue {
public $id; // string
public $values; // ArrayOf_xsd_string
}
Create object
$remoteField = new RemoteFieldValue ();
$remoteField->id = "12345";
$remoteField->value = "bla";
then call the method
$soap->updateIssue($auth,"ISSUEKEY", $remoteField );
Hope this help.
For me updateIssue works in such way (php)
Defining class (from wsdl)
class RemoteFieldValue
{
public $id; // string
public $values; // ArrayOf_xsd_string
}
after that here is a code which updates 'description' field at issue.
public function updateDescription($issue_key, $description)
{
$remoteField = new RemoteFieldValue ();
$remoteField->id = 'description';
$remoteField->values = array($description);
return $this->mSoapClient->updateIssue($this->mToken, $issue_key, array($remoteField));
}
精彩评论