Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem using Json

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)
    c.perform()
    result = json.loads(buf.getvalue())
    return result

Somebody please explain what is happening here.

Any help would be much appreciated.

Problem using Json

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)
    c.perform()
    result = json.loads(buf.getvalue())
    return result

Somebody please explain what is happening here.

Any help would be much appreciated.

Problem using JsonWhy am I getting 'Extra data' error from Ceilometer API?

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)
    c.perform()
    result = json.loads(buf.getvalue())
    return result

Somebody please explain what is happening here.

Any help would be much appreciated.