Hi Guys,
Is there a way to be able, using API, to list a table records (like we do with /tables/{tableId}/records) but listing a query result records?
thanks,
Hey @FahdERM -
There isn’t a direct way to call the results of a query, but you can apply filters to the endpoint you are hitting. Here is an example python function that has filters applied:
def getTableRecords(instance,table,limit,offset,key,direction = 'asc'):
########################FUNCTION DESCRIPTION#######################
#This actually makes the api calls to get data from a table.
#returns the data and the count of records NOT JUST THE DATA
###################################################################
url = 'https://'+instance+'/api/v3/tables/'+str(table)+'/records?limit='+str(limit)+'&offset='+str(offset)+'&sortBy=_sequenceNumber&sortDir='+direction+'&includeTotalCount=true&filterAggregator=all'
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0",
"Accept-Encoding": "*",
"Connection": "keep-alive",
"accept": "application/json",
"Authorization": key,
"Content-Type": "application/json",
"filters.0.field":"ezwlf_linebeing_audited",
"filters.0.functionType":"equal",
"filters.0.arg":"Line 2"
}
r = requests.get(url, headers=headers)
try:
totalCount = int(r.headers['x-total-count'])
r = r.json()
#print("here",r)
return(r,totalCount)
except:
r = r.json()
return(r,0)
The important bit for filters is:
This will only return results that match this filter.
Hope this helps!
Pete
Hey @Pete_Hartnett,
Thank you for this answer. It will absolutely help.
best regards,