1

SOAP APIを介してAutoTaskでタスクを作成する必要がある内部アプリケーションに取り組んでいます。アプリケーションは Python で作成され、SOAP 通信には suds を使用し、コードは次のようになります。

url = AUTOTASK_API_URL
t = HttpAuthenticated(username=AUTOTASK_API_USERNAME, password=AUTOTASK_API_PASSWORD)
client = Client(url, transport=t)
        
task = self.client.factory.create('Task')

task.ProjectID = PROJECT_ID
task.Title = 'title test'
task.StartDateTime = datetime.datetime.now()
task.EndDateTime =  datetime.datetime.now() + datetime.timedelta(days=1)
task.DepartmentID = DEPARTMENT_ID
task.TaskType= 2
task.Status = 1
task.EstimatedHours = 8.0
task.Priority = 0
task.IsVisibleInClientPortal = False

taskArray = self.client.factory.create('ArrayOfEntity')
taskArray.Entity = [task]

response = self.client.service.create([taskArray])

しかし、このコードはこの例外をスローしています:

ERROR    2013-09-04 17:06:22,921 client.py:656] <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://autotask.net/ATWS/v1_5/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:create>
         <ns0:Entities>
            <ns0:Entity xsi:type="ns0:Task">
               <ns0:id/>
               <ns0:ProjectID>[PROJECT_ID]</ns0:ProjectID>
               <ns0:Title>title test</ns0:Title>
               <ns0:StartDateTime>2013-09-04 17:06:20.434000</ns0:StartDateTime>
               <ns0:EndDateTime>2013-09-05 17:06:20.434000</ns0:EndDateTime>
               <ns0:DepartmentID>[DEPARTMENT_ID]</ns0:DepartmentID>
               <ns0:TaskType>2</ns0:TaskType>
               <ns0:Status>1</ns0:Status>
               <ns0:EstimatedHours>8.0</ns0:EstimatedHours>
               <ns0:Priority>0</ns0:Priority>
               <ns0:IsVisibleInClientPortal>False</ns0:IsVisibleInClientPortal>
            </ns0:Entity>
         </ns0:Entities>
      </ns0:create>
   </ns1:Body>
</SOAP-ENV:Envelope>

INFO     2013-09-04 17:06:22,927 views_test.py:8] Starting 

Error
Traceback (most recent call last):
  File "helpers.py", line 21, in add_task
    response = self.client.service.create([taskArray])
  File "suds\client.py", line 542, in __call__
    return client.invoke(args, kwargs)
  File "suds\client.py", line 602, in invoke
    result = self.send(soapenv)
  File "suds\client.py", line 657, in send
    result = self.failed(binding, e)
  File "suds\client.py", line 712, in failed
    r, p = binding.get_fault(reply)
  File "suds\bindings\binding.py", line 265, in get_fault
    raise WebFault(p, faultroot)
WebFault: Server raised fault: 'System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (1, 364). ---> System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
   at System.Xml.XmlConvert.ToInt64(String s)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read70_Task(Boolean isNullable, Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read5_Entity(Boolean isNullable, Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read136_create()
   at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer96.Deserialize(XmlSerializationReader reader)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   --- End of inner exception stack trace ---
   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()'
4

2 に答える 2

0

問題は、新しいものを作成したい場合でも ID フィールドに入力する必要があることでした。この場合、ID の値は 0 でなければなりません。

于 2014-02-06T15:38:50.850 に答える