Hello guys!
The famous "Backend error 400 Bad Request" error
I wanted to approach the subject with you for that I made a simple code that always returns me a 400 Bad Request.
The code below reads a file that contains 600 rics. The code then queries each ric 1 by 1 to return the set of options. (BFBB161806000.U, etc.)
# Rics (600)
universe = pd.read_csv('rics.csv', delimiter=',', header=None)
universe = universe.values.T.tolist()[0]
# --------------------------
# Get Ric Option
# --------------------------
for u in universe:
data_grid, err = ek.get_data(u,['BKGD_REF'])
time.sleep(4) # with or without..
after a few minutes I get the following error:
Traceback (most recent call last):
File "C:\thomsonreuters\demo.py", line 44, in <module>
data_grid, err = ek.get_data(u,['BKGD_REF'])
File "C:\Users\Utilisateur\AppData\Local\Programs\Python\Python36-32\lib\site-packages\eikon\data_grid.py", line 141, in get_data
result, err = eikon.json_requests.send_json_request(DataGrid_UDF_endpoint, payload, debug=debug, error=error)
File "C:\Users\Utilisateur\AppData\Local\Programs\Python\Python36-32\lib\site-packages\eikon\json_requests.py", line 88, in send_json_request
check_server_error(result)
File "C:\Users\Utilisateur\AppData\Local\Programs\Python\Python36-32\lib\site-packages\eikon\json_requests.py", line 138, in check_server_error
raise requests.HTTPError(error_message, response=server_response)
requests.exceptions.HTTPError: Backend error. 400 Bad Request
In the file eikon\Profile.py I see a timeout of 30s
self.application_id = application_id
self.port = get_scripting_proxy_port()
self.url = "http://localhost:{0}/api/v1/data".format(self.port)
self.streaming_url = "ws://localhost:{0}/?".format(self.port)
self.session = Session()
self.session.trust_env = False
self.timeout = 30
The 400 appears when the session expires? after 30s?
Are the get_data() sessions properly closed at the end ? is it possible to improve this? without putting a time.sleep of 60s .. the continuation of the code recovers data on each options therefore the treatment is still longer.
Thanks,