I have a flask app that needs to collect timesheet information from the user and add it to my quickbooks desktop enterprise 2023 account. I have a file quickbooks.qwc which is as follows:
<?xml version="1.0"?>
<QBWCXML>
<AppName>Vector Portal</AppName>
<AppID>{}</AppID>
<AppURL>http://127.0.0.1:5000/qbwc</AppURL>
<AppDescription>Integration with Vector Portal</AppDescription>
<AppSupport>http://localhost/support</AppSupport>
<UserName>Vector Portal</UserName>
<OwnerID>{}</OwnerID>
<FileID>{}</FileID>
<QBType>QBFS</QBType>
<Scheduler>
<RunEveryNMinutes>5</RunEveryNMinutes>
</Scheduler>
<IsReadOnly>false</IsReadOnly>
</QBWCXML>
and my auth.py file which has these routes:
QBWC_USERNAME = "I included my username here"
QBWC_PASSWORD = "I included my password here"
@auth.route("/qbwc", methods=["GET"])
def qwbc():
ticket = "15ceca03-a0ff-49d5-a0ed-a78e2c4a8c32"
auth_data = {
"username": QBWC_USERNAME,
"password": QBWC_PASSWORD,
"company_file": "C:\\Users\\Public\\Documents\\Intuit\\QuickBooks\\Company Files\\Vector.qbw",
}
# Load the content of the quickbooks.qwc file from the static folder
with open(
"website/static/dependencies/quickbooks.qwc", "r", encoding="utf-8"
) as qwc_file:
response_xml = qwc_file.read()
# Format the response_xml with the correct values
response_xml = response_xml.format(
"This is where I put my AppId",
"This is where I put my UserId",
"This is where I put my FileId",
)
return Response(response_xml, content_type="text/xml")
@auth.route("/qbwc", methods=["POST"])
def qbwc_post():
qb_request = request.data
if qb_request:
timesheet_data = generate_timesheet_data()
response_xml = "<![CDATA[<?xml version='1.0' ?>"
response_xml += "<QBXML>"
response_xml += "</QBXML>"
response_xml += "]]>"
return Response(response_xml, content_type="text/xml")
else:
return "No request data received."
def generate_timesheet_data():
timesheet_data = [
{
"employee": "John Doe",
"hours": 8,
"date": "2023-07-31",
"description": "Worked on project A",
},
{
"employee": "Jane Smith",
"hours": 6,
"date": "2023-07-31",
"description": "Worked on project B",
},
]
# Create the QBXML response based on the timesheet_data
qbxml_response = ""
for entry in timesheet_data:
qbxml_response += "<TimeTrackingAddRq>"
qbxml_response += "<EmployeeFullName>{}</EmployeeFullName>".format(
entry["employee"]
)
qbxml_response += "<Hours>{}</Hours>".format(entry["hours"])
qbxml_response += "<TxnDate>{}</TxnDate>".format(entry["date"])
qbxml_response += "<Notes>{}</Notes>".format(entry["description"])
qbxml_response += "</TimeTrackingAddRq>"
return qbxml_response
def post_timesheet_to_quickbooks():
timesheet_data = generate_timesheet_data()
response = {
"status": "success",
"message": "Timesheet data posted to QuickBooks successfully.",
}
return response
I am relatively new to using quickbooks qbwc however I have triple checked that all of my Id's and authentication details are correct. I connected my app to the qbwc application using my quickbooks.qwc file and am using all of the authentication values that were provided to me in the intuit developer "my apps" section. The error in my qbwc app is as follows:
Version:
Not provided by service
Message:
Authentication failed
Description:
QBWC1012: Authentication failed due to following error message.
Response is not well-formed XML. See QWCLog for more details. Remember to turn logging on.
I have tried the code in a number of different formats and tried using the zeep library but I get the same error no matter what. Ideally my app would connect to quickbooks desktop and post the user timesheet information when it is submitted by the user, however as of right now my main concern is just getting a positive connection between my Flask app and quickbooks.