AylanaVorster
3 years agoQrew Member
API Calls into Python
Hi all,
I'm quite struggling being able to select a field from the API responses. I'm using requests to do the initial call, but from there it's a jumble of XML and JSON and .loads and .dumps and xmltodict.parse and nothing has been working for me.
I'm doing an API_DoQuery call, and it's returning the normal things starting with:
<?xml version="1.0" ?>
<qdbapi>
<action>API_DoQuery</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<dbinfo>
<name>TABLE NAME TEMP</name>
<desc></desc>
</dbinfo>
<variables>
</variables>
<chdbids>
</chdbids>
<record>
and then all the records start, and form those records, I only need one or two fields of data, so I would love some method where I can have
array = API_data["FIELD NAME"]
or some other method just to get the data into workable forms. Otherwise, I'd have to handle the XML as a text file and go through each line in a way that
if "<field_name> is in i, then get the text right after it but before </field_name>
and it feels like a lot of unnecessary maupilation.
I would really appreciate some assistance.
Thank you!
------------------------------
Aylana Vorster
------------------------------
I'm quite struggling being able to select a field from the API responses. I'm using requests to do the initial call, but from there it's a jumble of XML and JSON and .loads and .dumps and xmltodict.parse and nothing has been working for me.
I'm doing an API_DoQuery call, and it's returning the normal things starting with:
<?xml version="1.0" ?>
<qdbapi>
<action>API_DoQuery</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<dbinfo>
<name>TABLE NAME TEMP</name>
<desc></desc>
</dbinfo>
<variables>
</variables>
<chdbids>
</chdbids>
<record>
and then all the records start, and form those records, I only need one or two fields of data, so I would love some method where I can have
array = API_data["FIELD NAME"]
or some other method just to get the data into workable forms. Otherwise, I'd have to handle the XML as a text file and go through each line in a way that
if "<field_name> is in i, then get the text right after it but before </field_name>
and it feels like a lot of unnecessary maupilation.
I would really appreciate some assistance.
Thank you!
------------------------------
Aylana Vorster
------------------------------