0

I have a Google Sheets form that has been set up to take form data, format it into a QBXML Invoice Add Request, then save it as a text document (.gdoc). My issue is that the QBFC C# sample code that I have found is all based around building the QBXML request and then sending that; I haven't been able to figure out how to send the ready-made QBXML document to Quickbooks Desktop as a request.

For example, this code doesn't work because DoRequests() needs to be passed an IMsgSetRequest and won't accept a string:

String xmlDoc = File.ReadAllText("J:\\My Drive\\XML Test Doc.gdoc");
IMsgSetResponse responseMsgSet = sessionManager.DoRequests(xmlDoc);

And this won't work either, because you can't convert form a string to an IMsgSetRequest:

String xmlDoc = File.ReadAllText("J:\\My Drive\\XML Test Doc.gdoc");
IMsgSetRequest requestMsgSet = xmlDoc;
IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);

I'm assuming (and hoping) that there's a simple solution that I'm just overlooking. But if there is, it's eluded me for long enough that I've decided that it's worth reaching out to you folks for assistance. Thanks in advance.

Derek Glissman
  • 67
  • 1
  • 1
  • 14

3 Answers3

1

The QBSessionManager has a .DoRequestsFromXMLString that you could pass the full XML string to (which you read from your file).

Its definition is:

IMsgSetResponse DoRequestsFromXMLString(string qbXMLRequest);
Ethan
  • 628
  • 2
  • 6
  • 20
0

You need to use QBXML instead of QBFC. QBFC is a wrapper that generates the QBXML. Since you already have the QBXML generated you can bypass QBFC. Include a reference to QBXMLRP2Lib and the following code should allow you to send the data to QuickBooks.

String xmlDoc = File.ReadAllText("J:\\My Drive\\XML Test Doc.gdoc");
QBXMLRP2Lib.IRequestProcessor5 rp = new QBXMLRP2Lib.RequestProcessor3();
rp.OpenConnection2("AppID", "AppName", QBXMLRP2Lib.QBXMLRPConnectionType.localQBD);
string ticket = rp.BeginSession("", QBXMLRP2Lib.QBFileMode.qbFileOpenDoNotCare);
string response = rp.ProcessRequest(ticket, xmlDoc);
Hpjchobbes
  • 1,309
  • 1
  • 8
  • 11
0

You may find that this tool helps: SDKTestPlus3. The tool handles the connection to Quickbooks Desktop and you can then pass your XML file over.

user3665624
  • 75
  • 1
  • 5