似乎无法让 app-engine 上的 protoRPC API 为我工作。
这是我的要求:
$.ajax({
url: '/guestRPC.get_tags',
type: 'POST',
contentType: 'application/json',
dataType: 'json',
data: {
prefix: JSON.stringify(request),
locale: JSON.stringify('{{locale}}')
},
success: somefunction
});
这是我根据浏览器调试器发送的内容:
Request Method:POST
Status Code:500 Internal Server Error
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,he;q=0.6
Connection:keep-alive
Content-Length:51
Content-Type:application/json
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.137 Safari/535.19
X-Requested-With:XMLHttpRequest
Request Payload
prefix=%7B%22term%22%3A%22%22%7D&locale=%22en_US%22
Response Headersview source
Cache-Control:no-cache
Content-Encoding:gzip
Content-Length:87
Date:Mon, 26 Mar 2012 18:58:24 GMT
Expires:Fri, 01 Jan 1990 00:00:00 GMT
Server:Google Frontend
Vary:Accept-Encoding
content-type:application/json
x-content-type-options:nosniff
这是服务器上的错误:
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=...
D2012-03-26 21:56:02.155
Entered guestRPC handler.
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)
E2012-03-26 21:56:02.159
Internal Server Error