Invalid JSON response from cPanel API

248 views Asked by At

I am using the cPanel UAPI but for some reason I am not receiving a valid JSON response with the additional curly braces and other quotations. I have tried different commands and on different servers and it's the same thing so I'm sure it's something simple I'm missing. Here is the doc I am following: https://api.docs.cpanel.net/openapi/cpanel/operation/query/

I've worked with other JSON APIs and I've never seen this before so is it cPanel specific and how would I parse this?:

---
apiversion: 3
func: query
module: Bandwidth
result:
  data:
    example.com:
      "1572580800": '2978386611'
      "1575176400": '3017940650'
      "1577854800": '1272949062'
      "1580533200": '1305954799'
      "1583038800": '1072552621'
      "1585713600": '1080945766'
      "1588305600": '1188271342'
      "1590984000": '1209022420'
      "1593576000": 825711372
      "1596254400": 771882286
      "1598932800": '1126013108'
      "1601524800": '1739977967'
      "1604203200": '1225180686'
      "1606798800": '1260268241'
      "1609477200": '1503779339'
      "1612155600": 985363356
      "1614574800": 289737623
    subdomain.example.com:
      "1572580800": 4054128
      "1575176400": 4187711
      "1577854800": 83997477
      "1580533200": 239566187
      "1583038800": 413164665
      "1585713600": 247957953
      "1588305600": 239197568
      "1590984000": 237783617
      "1593576000": 304554763
      "1596254400": 255965489
      "1598932800": 251708858
      "1601524800": 264273039
      "1604203200": 138803673
      "1606798800": 121939910
      "1609477200": 68686277
      "1612155600": 74725743
      "1614574800": 19763737
    UNKNOWN:
      "1572580800": 13288313
      "1575176400": 6326053
      "1577854800": 17962542
      "1580533200": 9835755
      "1583038800": 22566655
      "1598932800": 25137467
      "1604203200": 31783967
      "1606798800": 28088240
      "1609477200": 22907243
      "1612155600": 21413429
      "1614574800": 2085610
    subdomain1.example.com:
      "1604203200": 2107896
      "1606798800": 2516570
      "1609477200": 3454393
      "1612155600": 3216589
      "1614574800": 795065
    subdomain2.example.com:
      "1580533200": 557880
      "1583038800": 440351
      "1585713600": 183146
      "1588305600": 1047856
      "1590984000": 415107
      "1593576000": 342764
      "1596254400": 5887618
      "1598932800": 429651
  errors: ~
  messages: ~
  metadata: {}

  status: 1
  warnings: ~ ```
1

There are 1 answers

0
user3079103 On

cPanel got back to me and all I needed to do was to add --output=jsonpretty at the end.