通过qbXML为Employee设置IsActive

时间:2013-05-06 13:55:43

标签: intuit-partner-platform qbxml

使用QbXml添加或修改Employees时出现以下错误:QuickBooks在解析提供的XML文本流时发现错误。

我尝试过true / false(它返回的值),是/否和1/0;这似乎都不起作用。

是否可以为员工设置IsActive字段?我错过了什么吗?

谢谢!


抛出的异常是:

{System.Runtime.InteropServices.COMException (0x80040400): QuickBooks found an error when parsing the provided XML text stream.
   at Interop.QBXMLRP2.IRequestProcessor4.ProcessRequest(String ticket, String inputRequest)
   at PayrolImport.Program.Main(String[] args) in Program.cs:line 251
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()}

XML

<?xml version="1.0"?>
<?qbxml version="12.0"?>
<QBXML>
  <QBXMLMsgsRq onError="stopOnError">
    <EmployeeModRq>
      <EmployeeMod>
        <ListID>8000007D-1367847338</ListID>
        <EditSequence>1367850617</EditSequence>
        <FirstName>first name</FirstName>
        <MiddleName>middle name</MiddleName>
        <LastName>last name</LastName>
        <IsActive>true</IsActive>
        <Email></Email>
        <AccountNumber>1</AccountNumber>
      </EmployeeMod>
    </EmployeeModRq>
  </QBXMLMsgsRq>
</QBXML>

1 个答案:

答案 0 :(得分:1)

qbXML 中XML元素的顺序很重要

因此,如果QuickBooks OSR文档显示XML元素的顺序应为:

<ListID >IDTYPE</ListID> <!-- required -->
<EditSequence >STRTYPE</EditSequence> <!-- required -->
<IsActive >BOOLTYPE</IsActive> <!-- optional -->
... lots of other stuff here ... 

你发送这个:

<ListID>8000007D-1367847338</ListID>
<EditSequence>1367850617</EditSequence>
... lots of other stuff here ... 
<IsActive>true</IsActive>

然后你会得到那个错误:

  

(0x80040400):QuickBooks在解析提供的XML时发现错误   文本流。

该错误本质上是QuickBooks试图告诉您XML文档中有一些错误。

如果以正确的顺序发送节点,它将正常工作:

<ListID>8000007D-1367847338</ListID>
<EditSequence>1367850617</EditSequence>
<IsActive>true</IsActive>
<FirstName>first name</FirstName>
<MiddleName>middle name</MiddleName>
<LastName>last name</LastName>

作为旁注,如果您使用QuickBooks SDK附带的“XML Validator”工具,它将告诉您输入的任何XML消息的确切错误。

希望有所帮助!