# -----------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
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
------------------------------
Original Message:
Sent: 11-07-2019 17:20
From: David Choi
Subject: Looking for simplest example to access quickbase using python
I know that this is old...but I got here from a Google search for simple example so I wanted to help the next guy/gal out. Here is my "simplest example."
import requestsimport xmltodictfrom xml.etree import ElementTree as etimport pprintpp = pprint.PrettyPrinter(indent=2)yourEmail = 'your@email.here'yourPassword = 'verygoodpassword'aTableID = 'xxx5yyyyy'companyURLPrefix = 'joescookies'headers = { "Content-Type": "application/xml", "Accept-Charset": "utf-8", "QUICKBASE-ACTION": "API_Authenticate"}payload = et.Element('qdbapi')username = et.SubElement(payload, 'username')username.text = yourEmailpassword = et.SubElement(payload, 'password')password.text = yourPasswordhumanPayload = et.tostring(payload)url2 = f'https://{companyURLPrefix}.quickbase.com/db/main'resp = requests.post(url2, data=humanPayload, headers=headers)parsed = et.XML(resp.text)authticket = parsed.find('ticket').texturl3 = f'https://{companyURLPrefix}.quickbase.com/db/{aTableID}'headersGetDB = { "Content-Type": "application/xml", "Accept-Charset": "utf-8", "QUICKBASE-ACTION": "API_GetDBInfo"}payloadGetDB = et.Element('qdbapi')ticket = et.SubElement(payloadGetDB, 'ticket')ticket.text = authtickethumanPayloadGetDB = et.tostring(payloadGetDB)respgetdb = requests.post(url3, data=humanPayloadGetDB, headers=headersGetDB)parsedGetDB = et.XML(respgetdb.text)parsedGetDB.find('dbname').textparsedGetDB.find('lastModifiedTime').textparsedGetDB.find('lastRecModTime').textparsedGetDB.find('createdTime').textparsedGetDB.find('numRecords').textparsedGetDB.find('mgrID').textparsedGetDB.find('mgrName').textparsedGetDB.find('time_zone').textparsedGetDB.find('version').text
------------------------------
David Choi
Original Message:
Sent: 08-11-2018 17:02
From: krishnan chittur
Subject: Looking for simplest example to access quickbase using python
Can someone point me to examples that show how a quickbase/db can be accessed from the command line/using python -? We would like to access, add, delete, change records and create reports - and in addition to the GUI provided, do such using CLI tools and python (saw pybase on github, am having some difficulty with it - unless someone can provide a complete example -?)