I cannot create an issue via the SOAP API in PHP. I tried this:
$soapClient = new SoapClient("http://jira:9090/rpc/soap/jirasoapservice-v2?wsdl");
$token = $soapClient->login('user', 'pass');
$issue=array(
'type'=>3,
'priority'=>3,
'project'=>'XXX',
'duedate'=>time(),
'components'=>'',
'versions'=>'',
'fixVersions'=>'',
'assignee'=>'user1',
'reporter'=>'user1',
'environment'=>'',
'description'=>'test',
'summary'=>'test',
'timetracking'=>'',
'attachment'=>'',
'labels'=>''
);
$soapClient->createIssue($token, $issue);
But when I run this script, the new issue is not created in JIRA. Can somebody help me with this problem?
Make sure that:
user1
(from the issue fields) has permissions to be assignee and reporter for this project (try to do it manually) user
(from the authentication) has permissions to create new issues in this project (log in manually with the user and try to create an issue) The duedate'=>time()
is working fine for me. Actually, I took your code, changed the project,reporter and assingee names and it worked for me, under Jira 4.4.4 .
The weird thing is that if there was a problem you were suppose to get an error, how are you trying to execute the php file? try to run it manually to check for errors. To do that create a PHP file with the following header:
#!/usr/bin/php
give it running permissions chmod +x myscript.php
and execute it ./myscript.php
. If you are running it from your web server check /var/log/httpd/error_log
for errors. Make sure you have the SOAP installed :
[root@localhost]# cat /etc/php.d/soap.ini
; Enable soap extension module
extension=soap.so
If you find any error update the question.
Your issue query must be an object
$issueQuery = new stdClass;
All your fields must be in an array
$customFields = array();
Your customfields must be an object
$fieldOBJ = new stdClass;
$fieldOBJ->customfieldId = 'customfield_10237';
$fieldOBJ->key = '';
$fieldOBJ->values = array(utf8_encode($value));
Add it to the array
$customFields[] = $fieldOBJ;
Add the custom fields to the issue query (and other main fields)
$issueQuery->customFieldValues = $customFields;
Create the issue ($token is your connection)
$issueCreated = $soapClient->createIssue($token, $demande);
Thats it! The $issueCreated will be the returned issue Key
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.