brucelin
brucelin

Reputation: 1021

Best way to continue to query Quickbooks data

I have a problem with the qbxml.

I'm trying to migrate the qb customers, items etc to zohobooks. I want to grab 50 customers first from quickbooks and calling zohobooks apis to create contacts on there. and again another 50 customers from quickbooks and to zohobooks.

The problem is I'm sure how can I continue to query after calling the zohobooks apis?

When I tried to use the same iteratorID from the first query response I got nothing from QB.

I'm building desktop app using .net, please advise me the best option to track the migration and where I'm.

Assume that I have 150 customers and for some reason stopped migrating after 100customers, in this case how can I get the last 50 customers next time?

public string customerQueryXml()
{
    XmlDocument inputXMLDoc = new XmlDocument();
    inputXMLDoc.AppendChild(inputXMLDoc.CreateXmlDeclaration("1.0", null, null));
    inputXMLDoc.AppendChild(inputXMLDoc.CreateProcessingInstruction("qbposxml", "version=\"1.0\""));

    XmlElement qbXML = inputXMLDoc.CreateElement("QBPOSXML");
    inputXMLDoc.AppendChild(qbXML);

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

    XmlElement customerQueryRq = inputXMLDoc.CreateElement("CustomerQueryRq");
    qbXMLMsgsRq.AppendChild(customerQueryRq);
    //customerQueryRq.SetAttribute("requestID", "1");
    //customerQueryRq.SetAttribute("iterator", "Start");
    customerQueryRq.SetAttribute("requestID", "2");
    customerQueryRq.SetAttribute("iterator", "Continue");
    customerQueryRq.SetAttribute("iteratorID", "{A1601C19-C6DC-43C0-AE43-6F45088C39F2}");


    // for test only, read 10 customers
    XmlElement MaxReturned = inputXMLDoc.CreateElement("MaxReturned");
    customerQueryRq.AppendChild(MaxReturned).InnerText = "50";

    XmlElement ownerID = inputXMLDoc.CreateElement("OwnerID");
    customerQueryRq.AppendChild(ownerID).InnerText = "0";

    XmlElement timeModifiedRangeFilter = inputXMLDoc.CreateElement("TimeModifiedRangeFilter");
    customerQueryRq.AppendChild(timeModifiedRangeFilter);

    XmlElement fromTimeModified = inputXMLDoc.CreateElement("FromTimeModified");
    timeModifiedRangeFilter.AppendChild(fromTimeModified).InnerText = "1980-01-01T00:00:00";

    XmlElement toTimeModified = inputXMLDoc.CreateElement("ToTimeModified");
    timeModifiedRangeFilter.AppendChild(toTimeModified).InnerText = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");

    return inputXMLDoc.OuterXml;
}

EDIT: I noticed that I have to use the iteratorID in the same request. By the way I have no problem with the qbxml itself. My question is how can I continue to query the customers, items or whatever on another request?

Upvotes: 0

Views: 192

Answers (1)

Keith Palmer Jr.
Keith Palmer Jr.

Reputation: 27962

Iterators have to be used within a single Session. e.g. this will work:

  • Connect to QuickBooks (establish a session)
  • Do a request to create an iterator and get the first page of records
  • Do another request to continue the iterator
  • Do another request to continue the iterator

While this will not work, and is not something supported by QuickBooks:

  • Connect to QuickBooks (establish a session)
  • Do a request to create an iterator and get the first page of records
  • Disconnect
  • Do a request to create an iterator and get the first page of records

Upvotes: 1

Related Questions