我在Android应用程序中为Parse托管应用程序提供了基本的解析查询,例如find()
,但是现在我需要将其迁移到另一个平台,我将我的应用程序转移到AWS托管的Parse服务器。但现在一些查询无效。我怎样才能让他们再次工作?
以下是一个例子:
ParseQuery<ParseObject> query = ParseQuery.getQuery("Car");
query.orderByDescending(URLEncoder.encode("_created_at"));
query.whereWithinMiles("location", currentloc, 100 );
try {
ob = query.find();
} catch (ParseException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
我生成的请求类型如下:
Url : http://www.myapp.com/parse/classes/car
Method : POST
Headers : {X-Parse-OS-Version=6.0, Content-Type=application/json, X-Parse-App-Build-Version=1, X-Parse-Client-Key=, X-Parse-Installation-Id=a4be05643-0289-442b-8ab8-8a1beb30d016, X-Parse-App-Display-Version=1.0, X-Parse-Client-Version=a1.13.1, Content-Length=55, User-Agent=Parse Android SDK 1.13.1 (in.athenasoft.glimpse/1) API Level 23, X-Parse-Application-Id=GlimpseAppId, X-Parse-Session-Token=r:8486b0ada48b7asdfec58dc91e002a61}
Body : { "where": "{\"UserId\":\"lFqQpYcH3X\"}", "_method": "GET" }
上述查询适用于解析服务器,但不适用于AWS。
我的日志如下所示:
01-24 17:14:07.952 7740-8352/com.package.test I/ParseLogInterceptor: Request-Id : 4
01-24 17:14:07.952 7740-8352/com.package.test I/ParseLogInterceptor: Url : http://myserver.com/parse/classes/car
01-24 17:14:07.952 7740-8352/com.package.test I/ParseLogInterceptor: Method : POST
01-24 17:14:07.952 7740-8352/com.package.test I/ParseLogInterceptor: Headers : {X-Parse-OS-Version=6.0, Content-Type=application/json, X-Parse-App-Build-Version=1, X-Parse-Client-Key=, X-Parse-Installation-Id=a4be0316-0289-442b-8ab8-8a1beb30d016, X-Parse-App-Display-Version=1.0, X-Parse-Client-Version=a1.13.1, Content-Length=17, User-Agent=Parse Android SDK 1.13.1 (com.package.test/1) API Level 23, X-Parse-Application-Id=myappAppId, X-Parse-Session-Token=r:8486b0ada48b7971aec58dc91e002a61}
01-24 17:14:07.952 7740-8352/com.package.test I/ParseLogInterceptor: Body : {
"_method": "GET"
}
01-24 17:14:07.952 7740-8352/com.package.test I/ParseLogInterceptor: --------------
01-24 17:14:07.953 7740-8352/com.package.test I/System.out: [CDS][DNS] getAllByNameImpl netId = 0
01-24 17:14:07.954 7740-8352/com.package.test D/libc-netbsd: [getaddrinfo]: hostname=myserver.com; servname=(null); netid=0; mark=0
01-24 17:14:07.954 7740-8352/com.package.test D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
01-24 17:14:07.954 7740-8352/com.package.test D/libc-netbsd: [getaddrinfo]: hostname=myserver.com; servname=(null); netid=0; mark=0
01-24 17:14:07.954 7740-8352/com.package.test D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
01-24 17:14:07.959 7740-8352/com.package.test D/libc-netbsd: getaddrinfo: myserver.com get result from proxy gai_error = 0
01-24 17:14:07.960 7740-8352/com.package.test I/System.out: [CDS]rx timeout:10000
01-24 17:14:07.960 7740-8352/com.package.test I/System.out: [socket][5] connection myserver.com/35.167.7.84:80;LocalPort=48919(10000)
01-24 17:14:07.961 7740-8352/com.package.test I/System.out: [CDS]connect[myserver.com/35.167.7.84:80] tm:10
01-24 17:14:08.430 7740-8352/com.package.test I/System.out: [socket][/192.168.1.5:48919] connected
01-24 17:14:08.430 7740-8352/com.package.test I/System.out: [CDS]rx timeout:10000
01-24 17:14:08.430 7740-8352/com.package.test I/System.out: [CDS]SO_SND_TIMEOUT:0
01-24 17:14:08.431 7740-8352/com.package.test I/System.out: [OkHttp] sendRequest<<
01-24 17:14:08.947 7740-8352/com.package.test I/System.out: close [socket][/192.168.1.5:48919]
01-24 17:14:08.951 7740-7786/com.package.test E/Error: bad json response
01-24 17:14:08.951 7740-7786/com.package.test W/System.err: com.parse.ParseRequest$ParseRequestException: bad json response
01-24 17:14:08.952 7740-7786/com.package.test W/System.err: at com.parse.ParseRequest.newTemporaryException(ParseRequest.java:290)
01-24 17:14:08.954 7740-8370/com.package.test I/ParseLogInterceptor: Type : Response
01-24 17:14:08.954 7740-8370/com.package.test I/ParseLogInterceptor: Request-Id : 4
01-24 17:14:08.954 7740-8370/com.package.test I/ParseLogInterceptor: Status-Code : 200
01-24 17:14:08.954 7740-8370/com.package.test I/ParseLogInterceptor: Reason-Phrase : OK
01-24 17:14:08.955 7740-8370/com.package.test I/ParseLogInterceptor: Headers : {etag=W/"90c-jRFsH92iLnK0S38dRq90lQ", content-encoding=gzip, content-type=application/json; charset=utf-8, date=Tue, 24 Jan 2017 11:44:08 GMT, X-Android-Selected-Protocol=http/1.1, X-Android-Response-Source=NETWORK 200, connection=close, X-Android-Sent-Millis=1485258248430, vary=X-HTTP-Method-Override, Accept-Encoding, access-control-allow-headers=X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, Content-Type, transfer-encoding=chunked, access-control-allow-methods=GET,PUT,POST,DELETE,OPTIONS, x-powered-by=Express, access-control-allow-origin=*, X-Android-Received-Millis=1485258248938}
01-24 17:14:08.955 7740-8370/com.package.test I/ParseLogInterceptor: Body : { SOME HTML Returnered
}
01-24 17:14:08.955 7740-8370/com.package.test I/ParseLogInterceptor: --------------
01-24 17:14:08.952 7740-7786/com.package.test W/System.err: at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:308)
01-24 17:14:08.956 7740-7786/com.package.test W/System.err: at com.parse.ParseRequest$3.then(ParseRequest.java:137)
01-24 17:14:08.956 7740-7786/com.package.test W/System.err: at com.parse.ParseRequest$3.then(ParseRequest.java:133)
01-24 17:14:08.956 7740-7786/com.package.test W/System.err: at bolts.Task$15.run(Task.java:917)
01-24 17:14:08.956 7740-7786/com.package.test W/System.err: at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
01-24 17:14:08.956 7740-7786/com.package.test W/System.err: at bolts.Task.completeAfterTask(Task.java:908)
01-24 17:14:08.956 7740-7786/com.package.test W/System.err: at bolts.Task.continueWithTask(Task.java:715)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: at bolts.Task.continueWithTask(Task.java:726)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: at bolts.Task$13.then(Task.java:818)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: at bolts.Task$13.then(Task.java:806)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: at bolts.Task$15.run(Task.java:917)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: at java.lang.Thread.run(Thread.java:818)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: Caused by: org.json.JSONException: Value �������������ך�*���W�ӵ�ҋ�� of type java.lang.String cannot be converted to JSONObject
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: at org.json.JSON.typeMismatch(JSON.java:111)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: at org.json.JSONObject.<init>(JSONObject.java:160)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: at org.json.JSONObject.<init>(JSONObject.java:173)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:298)
01-24 17:14:08.957 7740-7786/com.package.test W/System.err: ... 13 more
01-24 17:14:08.976 7740-8373/com.package.test I/ParseLogInterceptor: Type : Request
01-24 17:14:08.976 7740-8373/com.package.test I/ParseLogInterceptor: Request-Id : 5
01-24 17:14:08.977 7740-8373/com.package.test I/ParseLogInterceptor: Url : http://myserver.com/parse/classes/carUsers
01-24 17:14:08.977 7740-8373/com.package.test I/ParseLogInterceptor: Method : POST
01-24 17:14:08.977 7740-8373/com.package.test I/ParseLogInterceptor: Headers : {X-Parse-OS-Version=6.0, Content-Type=application/json, X-Parse-App-Build-Version=1, X-Parse-Client-Key=, X-Parse-Installation-Id=a4be0316-0289-442b-8ab8-8a1beb30d016, X-Parse-App-Display-Version=1.0, X-Parse-Client-Version=a1.13.1, Content-Length=135, User-Agent=Parse Android SDK 1.13.1 (com.package.test/1) API Level 23, X-Parse-Application-Id=myappAppId, X-Parse-Session-Token=r:8486b0ada48b7971aec58dc91e002a61}
01-24 17:14:08.977 7740-8373/com.package.test I/ParseLogInterceptor: Body : {
"include": "carId",
"where": "{\"UserId\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"lFqQpYcH3X\"}}",
"_method": "GET"
}
01-24 17:14:08.977 7740-8373/com.package.test I/ParseLogInterceptor: --------------