For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 0

EikonError: Error code 500 | Backend error. Failed to deserialize backend response. Expected valid JSON

I used to be able to query the the get_news_headlines() method using the below string formatting. But since this year I have been getting this error, while using the same code. I can't figure out a way to amend the query and still get the desired results.

From what I can see it seems to be encoding the backslashs in a way that makes the query unusable. It did not used to do this. Are you aware of any changes that were made that might cause this, and any solutions?


Code:

fo_all_str = "(\\\"Platts FO\\\" AND \\\"SELLS\\\" AND \\\"190\\\") OR (\\\"Platts FO\\\" AND \\\"BUYS\\\" AND \\\"190\\\") OR (\\\"Platts Marine\\\" AND \\\"SELLS\\\" AND \\\"190\\\") OR (\\\"Platts Marine\\\" AND \\\"BUYS\\\" AND \\\"190\\\")"

fo_headlines = ek.get_news_headlines(fo_all_str, count=100, date_from='2021-05-14T01:00:00', date_to='2021-06-08T23:59:00')


Full Error Message:

EikonError: Error code 500 | Backend error. Failed to deserialize backend response. Expected valid JSON. Error: invalid character 'i' looking for beginning of value

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
39.2k 75 11 27

@owilliams

It looks like the latest version of Eikon Data APIs library v1.1.10 has the same problem as the eikon module in RDP Library. Can you downgrade the version of Eikon Data APIs library to v1.1.6.post3 by running

pip install eikon==1.1.6.post3
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
9.7k 49 38 60

Hi @owilliams,

There may have been a temporary issue with the server. Can you try again?

This is what happened when I tried just now:


ahs.png (92.6 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
1 0 0 0

Tried again, using Python3 version 3.7 and 3.8 and get the same result. It has been doing this to me for months now. May I ask what python version you are using? Not sure how to resolve this now that I see that it is working for you.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
1 0 0 0

Please find below the full error traceback, if it helps:


2021-06-09 21:06:33,123 P[33412] [MainThread 23108] Backend error. Failed to deserialize backend response. Expected valid JSON. Error: invalid character 'i' looking for beginning of value

2021-06-09 21:06:33,124 P[33412] [MainThread 23108] HTTP request failed: EikonError-Backend error. Failed to deserialize backend response. Expected valid JSON. Error: invalid character 'i' looking for beginning of value

Traceback (most recent call last):

File "C:\Users\ODW_W\anaconda3\envs\eikon_test\lib\site-packages\eikon\json_requests.py", line 124, in send_json_request

_check_server_error(result)

File "C:\Users\ODW_W\anaconda3\envs\eikon_test\lib\site-packages\eikon\json_requests.py", line 216, in _check_server_error

raise EikonError(int(server_response['ErrorCode']), error_message)

eikon.eikonError.EikonError: Error code 500 | Backend error. Failed to deserialize backend response. Expected valid JSON. Error: invalid character 'i' looking for beginning of value

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "<input>", line 1, in <module>

File "C:\Program Files\JetBrains\PyCharm Community Edition with Anaconda plugin 2019.1.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile

pydev_imports.execfile(filename, global_vars, local_vars) # execute the script

File "C:\Program Files\JetBrains\PyCharm Community Edition with Anaconda plugin 2019.1.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile

exec(compile(contents+"\n", file, 'exec'), glob, loc)

File "C:/Users/ODW_W/Documents/GitHub/motools/odw_tools/reports/sing_report.py", line 37, in <module>

fo_headlines = ek.get_news_headlines(fo_all_str, count=100, date_from='2021-05-14T01:00:00', date_to='2021-06-08T23:59:00')

File "C:\Users\ODW_W\anaconda3\envs\eikon_test\lib\site-packages\eikon\news_request.py", line 124, in get_news_headlines

result = eikon.json_requests.send_json_request(News_Headlines_UDF_endpoint, payload, debug=debug)

File "C:\Users\ODW_W\anaconda3\envs\eikon_test\lib\site-packages\eikon\json_requests.py", line 134, in send_json_request

raise EikonError(eikon_err.code, eikon_err.message)

eikon.eikonError.EikonError: Error code 500 | Backend error. Failed to deserialize backend response. Expected valid JSON. Error: invalid character 'i' looking for beginning of value

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
39.2k 75 11 27

@owilliams

Are you using Eikon Data APIs library or eikon module from RDP Library? In other words do you use

import eikon as ek

or

import refinitiv.dataplatform.eikon as ek

As far as I can see the problem you experienced is specific to eikon module in RDP Library. I don't reproduce it with Eikon Data APIs library. For this reason I suggest you use Eikon Data APIs library to retrieve news headlines from Eikon while we're working on addressing the problem in RDP Library.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
1 0 0 0

I've been using: import eikon as ek

I used pip to install eikon. I've tried a fresh installation and still get the same error.


I'm not familiar with the RDP library, or how to install that module.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Hi @owilliams,

Have you tried running your example in CodeBook? Just want to confirm you can get a valid answer back there so we can try to work backwards. You also mentioned this has been doing this for months now. Has it ever worked?

Upvotes
1 0 0 0

Thank you, that version seems to work fine for me.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea