Python Forum

Full Version: JSON Decode error when using API to create dataframe
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there. I am new to python and I'm attempting to use the capiq-python api to create a dataframe. I'm hoping that someone with a Capital IQ account would be able to debug the issue below. (Note that USERNAME and PASSWORD in the code below is in place of my actual username and password

When I run this code script (I've run it in R using the Reticulate package)

from capiq.capiq_client import CapIQClient
ciq_client = CapIQClient("USERNAME", "PASSWORD")
data = ciq_client.gdshe(['WMT:', "ibm:"],['IQ_CLOSEPRICE'], ['close_price'], start_date='11/12/2010',end_date='11/18/2010')
data_content = json.loads(data)
I get the following error

Error in py_run_file_impl(file, local, convert) : 
  JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Any ideas on how to debug this? TIA!
Looking at the source code you don't get JSON string but dict object. i.e. the python wrapper processed the json string that was returned from the request. So don't do json.loads(). Print data and type(data) so that you see what you actually get.
@buran using print(data) still gives the same error. Could it have something to do with the square brackets I have in my code chunk?"[]"
can you show the full traceback you get? I think square brackets are not the problem, but not sure about 'WMT:', "ibm:" All that said - I am not familiar with that API or the wrapper and the docs are really scarce.
actually, looking at the tests, it seems ok.
there is exactly the same line. I guess you took it from there.

print(client.gdshe(['WMT:', "ibm:"],['IQ_CLOSEPRICE'], ['close_price'], start_date='11/12/2010',end_date='11/18/2010'))
Please, when you cross-post, let us know
https://stackoverflow.com/questions/6567...-in-python