-1

我想通过我的 .Net 应用程序更新 QuickBook 数据,如客户地址、发票地址等。我能够通过 API 获取所有 QuickBook 数据,但我无法更新 QuickBook 数据。

更新功能

StringBuilder strXML = new StringBuilder(string.Empty);
            XmlDocument inputXMLDoc = new XmlDocument();
            inputXMLDoc.AppendChild(inputXMLDoc.CreateXmlDeclaration("1.0", null, null));
            inputXMLDoc.AppendChild(inputXMLDoc.CreateProcessingInstruction("qbxml", "version=\"8.0\""));
            XmlElement qbXML = inputXMLDoc.CreateElement("QBXML");
            inputXMLDoc.AppendChild(qbXML);

            XmlElement qbXMLMsgsRq = inputXMLDoc.CreateElement("QBXMLMsgsRq");
            qbXML.AppendChild(qbXMLMsgsRq);
            qbXMLMsgsRq.SetAttribute("onError", "stopOnError");

            XmlElement custModeRq = inputXMLDoc.CreateElement("CustomerModRq");
            qbXMLMsgsRq.AppendChild(custModeRq);
            custModeRq.SetAttribute("requestID", "15");

            XmlElement custMod = inputXMLDoc.CreateElement("CustomerMod");
            custModeRq.AppendChild(custMod);

            XmlElement ListId = inputXMLDoc.CreateElement("ListID");
            custMod.AppendChild(ListId);
            ListId.InnerText = _listID;

            XmlElement EditSequence = inputXMLDoc.CreateElement("EditSequence");
            custMod.AppendChild(EditSequence);
            EditSequence.InnerText = _editSequence;

            XmlElement Name = inputXMLDoc.CreateElement("Name");
            custMod.AppendChild(Name);
            Name.InnerText = "Jack Sparrow";

            string s = QuickbooksAPI.APIBase.GetQBQueryResponce(inputXMLDoc.OuterXml);

            return inputXMLDoc.OuterXml;

获取请求/响应函数

RequestProcessor2 rp = null;
                string ticket = null;
                string response = null;
                try
                {
                    rp = new RequestProcessor2();
                    rp.OpenConnection("", "Stamps.com");
                    //rp.OpenConnection2("", "Stamps.com",QBXMLRPConnectionType.localQBDLaunchUI);
                    ticket = rp.BeginSession("", QBFileMode.qbFileOpenDoNotCare);
                    response = rp.ProcessRequest(ticket, strRequest);
                }
                catch (System.Runtime.InteropServices.COMException ex)
                {
                    //MessageBox.Show("COM Error Description = " + ex.Message, "COM error");                    
                    return "";
                }
                finally
                {
                    if (ticket != null)
                    {
                        rp.EndSession(ticket);
                    }
                    if (rp != null)
                    {
                        rp.CloseConnection();
                    }
                };

预先感谢。

4

1 回答 1

1

在请求 XML 下方设置。

XML 格式:

<?xml version="1.0"?>

<?qbxml version="8.0"?>
<QBXML>
  <QBXMLMsgsRq onError="stopOnError">
    <CustomerModRq requestID="15">
      <CustomerMod>
        <ListID>9D84-1182061418</ListID>
        <EditSequence>1481791846</EditSequence>
        <BillAddress>
          <Addr1>addr1</Addr1>
          <Addr2>addr2</Addr2>
          <City>City</City>
          <State>State</State>
          <PostalCode>382007</PostalCode>
        </BillAddress>
      </CustomerMod>
    </CustomerModRq>
  </QBXMLMsgsRq>
</QBXML>
于 2013-09-24T10:14:37.767 回答