Forum Discussion
Udaya_NarayanaP
Qrew Member
# -----------Using the authticket we can actually do some work--------------
# this example is to get the API_GetDBInfo
url4 = f'https://{companyURLPrefix}.quickbase.com/db/{aTableID}'
headersGetDB = {
"Content-Type": "application/xml",
"Accept-Charset": "utf-8",
"QUICKBASE-ACTION": "API_GenResultsTable"
}
# build another XML payload
payloadGetDB = et.Element('qdbapi')
ticket = et.SubElement(payloadGetDB, 'ticket')
ticket.text = authticket
#print(et.tostring(payloadGetDB))
apptoken = et.SubElement(payloadGetDB, 'apptoken')
apptoken.text = 'xxxxxx'
#print(et.tostring(payloadGetDB))
qid = et.SubElement(payloadGetDB, 'qid')
#qid's are 1 & 2 & 9 for reporting list
qid.text = '9'
jht = et.SubElement(payloadGetDB, 'jht')
#qid's are 1 & 2 & 9 for reporting list
jht.text = '1'
fmt = et.SubElement(payloadGetDB, 'fmt')
fmt.text = 'structured'
#print(et.tostring(payloadGetDB))
options = et.SubElement(payloadGetDB, 'options')
options.text = 'num-4.sortorder-D'
#print(et.tostring(payloadGetDB))
#slist = et.SubElement(payloadGetDB, 'slist')
#slist.text = '7.23'
#make the payload ready for shipping
print("\n\n\n\n\n\n\n\n\n...................printing before API_GenResultsTable................\n\n\n\n\n\n\n\n\n")
humanPayloadGetDB = et.tostring(payloadGetDB)
print(humanPayloadGetDB)
pp.pprint(url4)
respgetdb = requests.post(url4, data=humanPayloadGetDB, headers=headersGetDB)
print("\n\n\n\n\n\n\n\n\nprinting API_GenResultsTable................\n\n\n\n\n\n\n\n\n")
pp.pprint(respgetdb.text)
print(et.XML(respgetdb.text).find('errtext').text) # this checks for the errtext
pp.pprint(vars(respgetdb)) # this pumps out the full response
# This makes the response a little nicer to sort through
parsedGetDB = et.XML(respgetdb.text)
# This is some of the info enbedded into the XML response.
print(parsedGetDB)
I am getting below error
------------------------------
Udaya Narayana Pakalapati
------------------------------
# this example is to get the API_GetDBInfo
url4 = f'https://{companyURLPrefix}.quickbase.com/db/{aTableID}'
headersGetDB = {
"Content-Type": "application/xml",
"Accept-Charset": "utf-8",
"QUICKBASE-ACTION": "API_GenResultsTable"
}
# build another XML payload
payloadGetDB = et.Element('qdbapi')
ticket = et.SubElement(payloadGetDB, 'ticket')
ticket.text = authticket
#print(et.tostring(payloadGetDB))
apptoken = et.SubElement(payloadGetDB, 'apptoken')
apptoken.text = 'xxxxxx'
#print(et.tostring(payloadGetDB))
qid = et.SubElement(payloadGetDB, 'qid')
#qid's are 1 & 2 & 9 for reporting list
qid.text = '9'
jht = et.SubElement(payloadGetDB, 'jht')
#qid's are 1 & 2 & 9 for reporting list
jht.text = '1'
fmt = et.SubElement(payloadGetDB, 'fmt')
fmt.text = 'structured'
#print(et.tostring(payloadGetDB))
options = et.SubElement(payloadGetDB, 'options')
options.text = 'num-4.sortorder-D'
#print(et.tostring(payloadGetDB))
#slist = et.SubElement(payloadGetDB, 'slist')
#slist.text = '7.23'
#make the payload ready for shipping
print("\n\n\n\n\n\n\n\n\n...................printing before API_GenResultsTable................\n\n\n\n\n\n\n\n\n")
humanPayloadGetDB = et.tostring(payloadGetDB)
print(humanPayloadGetDB)
pp.pprint(url4)
respgetdb = requests.post(url4, data=humanPayloadGetDB, headers=headersGetDB)
print("\n\n\n\n\n\n\n\n\nprinting API_GenResultsTable................\n\n\n\n\n\n\n\n\n")
pp.pprint(respgetdb.text)
print(et.XML(respgetdb.text).find('errtext').text) # this checks for the errtext
pp.pprint(vars(respgetdb)) # this pumps out the full response
# This makes the response a little nicer to sort through
parsedGetDB = et.XML(respgetdb.text)
# This is some of the info enbedded into the XML response.
print(parsedGetDB)
I am getting below error
print(et.XML(respgetdb.text).find('errtext').text) # this checks for the errtext
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 1315, in XML
parser.feed(text)
xml.etree.ElementTree.ParseError: syntax error: line 1, column 0
------------------------------
Udaya Narayana Pakalapati
------------------------------
AustinK
5 years agoQrew Commander
Do you know for a fact that the XML being returned is actual XML and not some big error itself? The error you got is what happens when the thing you are trying to parse is not XML.
Your best bet is going to be to break the code into parts and run the things individually line by line until you hit the issue. Try and pull an XML response and manually check that response to see if it is what you expect it to be.
Your best bet is going to be to break the code into parts and run the things individually line by line until you hit the issue. Try and pull an XML response and manually check that response to see if it is what you expect it to be.