Hello everyone,
I have searched far and wide and tried a great deal of things, but was not able to get this working…
I am trying to build my own Rest library that pushes/pulls data from the Epicor Rest API. I am successfully running BO methods as well as BAQs, but I would like to make sure I can also run BAQs with params, this is the part I’m struggling with at the moment.
Here’s my python function (which works with BAQs that don’t have params):
#import http.client
#conn = http.client.HTTPSConnection(self.url)
def execute_baq(self, baq_name, params):
headers = {"Authorization": "Bearer " + str(self.token)} #this part works
self.conn.request("GET", self.epicor_env + self.api_v + "/BaqSvc/" + baq_name, params, headers)
res = self.conn.getresponse()
data = res.read()
return data.decode("utf-8")
When I run the function, I’m pushing something along the lines of:
connection = EpicorConnection("username", "password", "env")
# I have also tried
# params = {'first' : 'first', 'second': 'second'} ..., but there's a type error when using this as params.
params = "@full_name eq 'john doe' and @emp_id eq '1144' and @monday eq '7:00 - 17:30'"
print(connection.execute_baq("TestBAQ6", params))
I have applied these inside the BAQ in Epicor and it they work.
This code works with BAQs that have no params. Here I am getting no data returned.
{
"odata.metadata":"url/api/v1/BaqSvc/TestBAQ6/$metadata#Epicor.DynamicQuery.QueryResults","value":[
]
}
I have tried many variations of params. Without the @, with $, replaced “eq” with “=”,“==”, etc…
Does anyone have an idea on how the params need to be structured or passed into this http.client method?
Thank you!