Im trying to add issues via soap api but it looks like im either doing something wrong (plausible, i have to admit, since its my first time ever using soap or mantis), or there is a bug.
Ill add way to reproduce what im doing so you can confirm if im stupid or there is a bug.
I am using python soap client called suds which everybody could download here (https://fedorahosted.org/releases/s/u/s ... 4.1.tar.gz)
If you have downloaded it and unpacked do something like this in (linux) shell:
python #opens python shell
in python shell:
Code: Select all
import sys
sys.path.append('/path/to/unpacked/python-suds-0.4.1')
user = 'youusername'
pwd = 'yourpassword'
wdsl = 'http://domain/mantisbt/api/soap/mantisconnect.php?wsdl'
from suds.client import Client #if this lane raises error, then the path you used to append to pythonpath was wrong.
client = Client(wdsl)
result = client.service.mc_version() # for me this is 1.2.10. I also tested it with 1.3-dev - got same results
issue = client.factory.create('IssueData')
project = client.factory.create('ObjectRef')
project.id = 19
project.name = "your project name"
issue = client.factory.create('IssueData')
issue.project = project
reporter = client.factory.create('AccountData')
reporter.name = 'name'
reporter.real_name = 'random text'
reporter.email = 'you@domain.com'
issue.reporter = reporter
issue.summary = 'test test test'
issue.description = u'just testing'
issue.category = 'Bug'
customfields = client.factory.create('CustomFieldValueForIssueDataArray')
client_field = client.factory.create('ObjectRef')
contact_field = client.factory.create('ObjectRef')
client_field.id = 1
client_field.name = 'Client'
contact_field.id = 4
contact_field.name = 'Contact'
contact_data = client.factory.create('CustomFieldValueForIssueData')
contact_data.field = contact_field
contact_data.value = 'random@domain.com'
client_data = client.factory.create('CustomFieldValueForIssueData')
client_data.field = client_field
client_data.value = 'something'
customfields.items = [client_data, contact_data]
issue.custom_fields = customfields
client.service.mc_issue_add(user, pwd, issue)
then i get error from php side:
WebFault: Server raised fault: 'Error Type: SYSTEM NOTICE,
Error Description:
Undefined index: field,
Stack Trace:
mc_issue_api.php L663 mci_issue_set_custom_fields(<string>'1992', <Array> { ['items'] => <Array> { [0] => <Array> { ['field'] => <Array> { ['id'] => 4, ['name'] => 'Contact' }, ['value'] => 'random@domain.com' }, [1] => <Array> { ['field'] => <Array> { ['id'] => 1, ['name'] => 'Client' }, ['value'] => 'Testing' } } }, <boolean>false)
UnknownFile L? mc_issue_add(<string>'yoursername', <string>'yourpassword', <Array> { ['project'] => <Array> { ['id'] => 19, ['name'] => 'yourproject' }, ['category'] => 'Support', ['reporter'] => <Array> { ['name'] => 'test-from-web', ['real_name'] => 'yoursername tests adding use via soap', ['email'] => 'random@domain.com' }, ['summary'] => 'test test test', ['description'] => 'just testing SOAP api', ['custom_fields'] => <Array> { ['items'] => <Array> { [0] => <Array> { ['field'] => <Array> { ['id'] => 4, ['name'] => 'Contact' }, ['value'] => 'random@domain.com' }, [1] => <Array> { ['field'] => <Array> { ['id'] => 1, ['name'] => 'Client' }, ['value'] => 'Testing' } } } })
nusoap.php L4087 call_user_func_array(<string>'mc_issue_add', <Array> { [0] => 'yoursername', [1] => 'yourpassword', [2] => <Array> { ['project'] => <Array> { ['id'] => 19, ['name'] => 'yourproject' }, ['category'] => 'Support', ['reporter'] => <Array> { ['name'] => 'test-from-web', ['real_name'] => 'yoursername tests adding use via soap', ['email'] => 'random@domain.com' }, ['summary'] => 'test test test', ['description'] => 'just testing SOAP api', ['custom_fields'] => <Array> { ['items'] => <Array> { [0] => <Array> { ['field'] => <Array> { ['id'] => 4, ['name'] => 'Contact' }, ['value'] => 'random@domain.com' }, [1] => <Array> { ['field'] => <Array> { ['id'] => 1, ['name'] => 'Client' }, ['value'] => 'Testing' } } } } })
nusoap.php L3718 invoke_method()
mantisconnect.php L1717 service(<string>'<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:ns3="http://futureware.biz/mantisconnect" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header/><ns1:Body><ns3:mc_issue_add><username xsi:type="ns2:string">yoursername</username><password xsi:type="ns2:string">yourpassword</password><issue xsi:type="ns3:IssueData"><project xsi:type="ns3:ObjectRef"><id xsi:type="ns2:integer">19</id><name xsi:type="ns2:string">yourproject</name></project><category xsi:type="ns2:string">Support</category><reporter xsi:type="ns3:AccountData"><name xsi:type="ns2:string">test-from-web</name><real_name xsi:type="ns2:string">yoursername tests adding use via soap</real_name><email xsi:type="ns2:string">random@domain.com</email></reporter><summary xsi:type="ns2:string">test test test</summary><description xsi:type="ns2:string">just testing SOAP api</description><custom_fields xsi:type="ns3:CustomFieldValueForIssueDataArray"><items xsi:type="ns3:CustomFieldValueForIssueData"><field xsi:type="ns3:ObjectRef"><id xsi:type="ns2:integer">4</id><name xsi:type="ns2:string">Contact</name></field><value xsi:type="ns2:string">random@domain.com</value></items><items xsi:type="ns3:CustomFieldValueForIssueData"><field xsi:type="ns3:ObjectRef"><id xsi:type="ns2:integer">1</id><name xsi:type="ns2:string">Client</name></field><value xsi:type="ns2:string">Testing</value></items></custom_fields></issue></ns3:mc_issue_add></ns1:Body></SOAP-ENV:Envelope>')
WebFault: Server raised fault: 'Error Type: SYSTEM NOTICE,
Error Description: Undefined index: field'
By the way - if i use soap api to post SINGLE custom field like:
Code: Select all
customfields.items = [client_data]
issue.custom_fields = customfields
client.service.mc_issue_add(user, pwd, issue)
If anyone could provide some feedback then i would appreciate it alot.
Thanks,
Alan