0

Based on the limited documentation I can found I have written the following code:

import win32com.client
import xml.etree.ElementTree as Et

newSession = win32com.client.Dispatch("QBXMLRP2Lib.RequestProcessor2") 

but I am getting the following error:

>Traceback (most recent call last):
>  File "C:\Users\Clear\AppData\Local\Programs\Python\Python37\lib\site->packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
>    IDispatch = pythoncom.connect(IDispatch)
>pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
>
>During handling of the above exception, another exception occurred:
>
>Traceback (most recent call last):
>  File >"C:\Users\Clear\AppData\Local\Programs\Python\Python37\learn_win32com.py", >line 4, in <module>
>    newSession = win32com.client.Dispatch("QBXMLRP2Lib.RequestProcessor2")
>  File "C:\Users\Clear\AppData\Local\Programs\Python\Python37\lib\site->packages\win32com\client\__init__.py", line 95, in Dispatch
>    dispatch, userName = >dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
>  File "C:\Users\Clear\AppData\Local\Programs\Python\Python37\lib\site->packages\win32com\client\dynamic.py", line 114, in >_GetGoodDispatchAndUserName
>    return (_GetGoodDispatch(IDispatch, clsctx), userName)
>  File "C:\Users\Clear\AppData\Local\Programs\Python\Python37\lib\site->packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
>    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, >pythoncom.IID_IDispatch)
>pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

I am new to COM and win32com and still in the beginning stages of programming.

Can you help me understand what I am doing wrong?

Zishe Schnitzler
  • 151
  • 2
  • 10

1 Answers1

0

It is working now.

My problem was that I was trying to do troubleshoot each step separately, so I tried running just win32com.client.Dispatch:

sessionManager = win32com.client.Dispatch("QBXMLRP2.RequestProcessor")

Creating a class that includes win32com.client.Dispatch + OpenConnection + BeginSession worked beautifully:

sessionManager = win32com.client.Dispatch("QBXMLRP2.RequestProcessor")
sessionManager.OpenConnection('', "My test app")
ticket = sessionManager.BeginSession('', 0)
return (sessionManager,ticket)

I hope this helps someone down the line.

Zishe Schnitzler
  • 151
  • 2
  • 10