Getting a "no JSON object could be decoded" error

302 views
Skip to first unread message

Uri

unread,
Mar 21, 2012, 9:59:19 PM3/21/12
to google-prot...@googlegroups.com
This is my request:

$.ajax({
url: '/guestRPC.get_tags',
type: 'POST',
contentType: 'application/json',
dataType: 'json',
data: {
prefix: JSON.stringify(request),
locale: JSON.stringify('{{locale}}')
},
success: somefunction
});

Getting a no JSON object could be decoded error.
What am I doing wrong?

Thanks

Rafe Kaplan

unread,
Mar 22, 2012, 4:05:22 PM3/22/12
to google-prot...@googlegroups.com
Have you checked the server logs to see what the stack trace looks
like for this application? It will indicate where the problem might
be.

I'm wondering if it's also possible that the json encoder does not
write objects the way that proto-rpc expects. Can you use your
browses debugger to look at the actual content of the ajax request?

--
 - Rafe Kaplan

Uri

unread,
Mar 26, 2012, 3:01:11 PM3/26/12
to google-prot...@googlegroups.com
  1. This is what I'm sending:

    1. Request Method:
      POST
    2. Status Code:
      500 Internal Server Error
    3. Request Headersview source
      1. Accept:
        application/json, text/javascript, */*; q=0.01
      2. Accept-Charset:
        ISO-8859-1,utf-8;q=0.7,*;q=0.3
      3. Accept-Encoding:
        gzip,deflate,sdch
      4. Accept-Language:
        en-US,en;q=0.8,he;q=0.6
      5. Connection:
        keep-alive
      6. Content-Length:
        51
      7. Content-Type:
        application/json
      8. User-Agent:
        Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.137 Safari/535.19

      9. X-Requested-With:
        XMLHttpRequest
    4. Request Payload
      1. prefix=%7B%22term%22%3A%22%22%7D&locale=%22en_US%22
    5. Response Headersview source
      1. Cache-Control:
        no-cache
      2. Content-Encoding:
        gzip
      3. Content-Length:
        87
      4. Date:
        Mon, 26 Mar 2012 18:58:24 GMT
      5. Expires:
        Fri, 01 Jan 1990 00:00:00 GMT
      6. Server:
        Google Frontend
      7. Vary:
        Accept-Encoding
      8. content-type:
        application/json
      9. x-content-type-options:
        nosniff

    And this is the error on server:

    2012-03-26 21:56:02.161 /guestRPC.get_tags 500 152ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.137 Safari/535.19
    - - - [26/Mar/2012:11:56:02 -0700] "POST /guestRPC.get_tags HTTP/1.1" 500 238 "mysite" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.137 Safari/535.19" "mysite" ms=152 cpu_ms=0 api_cpu_ms=0 cpm_usd=0.000138 pending_ms=86 instance=...
  2. D2012-03-26 21:56:02.155
    Entered guestRPC handler.
  3. E2012-03-26 21:56:02.156
    An unexpected error occured when handling RPC: No JSON object could be decoded: line 1 column 0 (char 0)
    Traceback (most recent call last):
      File "/base/python_runtime/python_lib/versions/1/protorpc/webapp/service_handlers.py", line 601, in handle
        request = mapper.build_request(self, method_info.request_type)
      File "/base/python_runtime/python_lib/versions/1/protorpc/webapp/service_handlers.py", line 235, in build_request
        return self.__protocol.decode_message(request_type, handler.request.body)
      File "/base/python_runtime/python_lib/versions/1/protorpc/protojson.py", line 156, in decode_message
        dictionary = json.loads(encoded_message)
      File "/base/python_runtime/python_lib/versions/1/simplejson/__init__.py", line 388, in loads
        return _default_decoder.decode(s)
      File "/base/python_runtime/python_lib/versions/1/simplejson/decoder.py", line 402, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/base/python_runtime/python_lib/versions/1/simplejson/decoder.py", line 420, in raw_decode
        raise JSONDecodeError("No JSON object could be decoded", s, idx)
    JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)
  4. E2012-03-26 21:56:02.159
    Internal Server Error

On Thursday, March 22, 2012 10:05:22 PM UTC+2, Rafe Kaplan wrote:
 Have you checked the server logs to see what the stack trace looks
like for this application?  It will indicate where the problem might
be.

  I'm wondering if it's also possible that the json encoder does not
write objects the way that proto-rpc expects.  Can you use your
browses debugger to look at the actual content of the ajax request?

Uri

unread,
Mar 26, 2012, 3:09:36 PM3/26/12
to google-prot...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages