UAPI: SyntaxError in JSON.parse

behinam

Well-Known Member
May 9, 2017
77
5
58
Dubay
cPanel Access Level
Root Administrator
I want to get the JSON results of UAPI and parse it in my Python program. It seems there is something wrong with the JSON output of the api.
I run the following command:
'uapi --user=myuser --output=json Bandwidth query grouping=year_month'
and get the results:
{"apiversion":3,"module":"Bandwidth","func":"query","result":{"data":{"1514752200":263337219892,"1543609800":145884299586,"1538339400":119656400553,"1541017800":172890529729,"1519849800":114107934353,"1546288200":88071820650,"1527795000":132312176767,"1509481800":313760720498,"1517430600":115307443541,"1504207800":508826138914,"1535743800":123868059627,"1501529400":48003795128,"1533065400":126802068190,"1522524600":121649274903,"1506803400":314056226618,"1525116600":135102301157,"1530387000":139453841103,"1512073800":237340430641},"warnings":null,"status":1,"messages":null,"errors":null,"metadata":{}}
But when I want to parse the results I get the following error in Python:
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 2 column 1 (char 609)
and of course on Mozilla Firefox I get the following error:
SyntaxError: JSON.parse: end of data after property value in object at line 2 column 1 of the JSON data
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
But when I want to parse the results I get the following error in Python:
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 2 column 1 (char 609)
Hello @behinam,

Can you go over the information in the post linked below and let us know if it helps explain why you are facing this issue?

SOLVED - Invalid JSON in WHM Api 1?

It's not for UAPI, but it looks to relate to the same problem you are reporting.

Thank you.