Why am I getting 'Extra data' error from Ceilometer API?

asked 2013-05-05 22:11:30 -0500

neumerance gravatar image

updated 2013-05-06 17:41:36 -0500

smaffulli gravatar image

I was trying to get result from ceilometer API using json and I was stuck with this error.

Extra data: line 1 column 1053 - line 1 column 11583 (char 1053 - 11583)

and this is my code.

import json, requests
import urllib
import urllib2
import pycurl
import cStringIO

c = pycurl.Curl()
buf = cStringIO.StringIO()

def get_resources(request, endpoint, lookup, filter=None):
    token = request.user.token.id
    url = endpoint+lookup

    c.setopt(c.URL, url)
    if filter:
        params = urllib.urlencode(filter)
        c.setopt(c.POSTFIELDS, params)
    c.setopt(c.CONNECTTIMEOUT, 5)
    c.setopt(c.TIMEOUT, 8)
    c.setopt(c.FAILONERROR, True)
    c.setopt(c.HTTPHEADER, ['X-Auth-Token: %s' % token, 'Content-Type:application/json'])
    c.setopt(c.WRITEFUNCTION, buf.write)
    result = json.loads(buf.getvalue())
    return result

Somebody please explain what is happening here.

Any help would be much appreciated.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-05-06 06:42:46 -0500

unmesh-gurjar gravatar image

There are two things you can look into: 1> set the HTTP header 'ACCEPT:application/json' (will ensure API returns a JSON response only) 2> Inspect the API return value (if not a well formed json, I think you should file a bug for the API).

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools


Asked: 2013-05-05 22:11:30 -0500

Seen: 321 times

Last updated: May 06 '13