Android 解析平台 ParseRequestException:错误 json 响应
Android Parse Platform ParseRequestException: bad json response
所以我正在尝试用 Parse 做一个项目,但我的开端真的很糟糕。
按照文档中的步骤进行操作后,我尝试执行任何请求(登录、对象创建),但在等待很长时间(总是超过 10-15 秒)后,我收到如下所示的错误:
com.parse.ParseRequest$ParseRequestException: bad json response
Caused by: org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
在浏览了所有存在的问题和答案后,我发现这种情况通常有两个原因:
初始化中的 link 是否缺少“/”
该应用程序没有连接
我已经通过调试排除了这两种可能性,但我仍然发现自己卡住了。
非常感谢此时的任何帮助。
这一行下面是完整的 Logcat 我有,前 3 行是我的日志,其余的是错误生成的。
E/error: bad json response
E/error code =: 100
E/error toString: com.parse.ParseRequest$ParseRequestException: bad json response
W/System.err: com.parse.ParseRequest$ParseRequestException: bad json response
W/System.err: at com.parse.ParseRequest.newTemporaryException(ParseRequest.java:290)
W/System.err: at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:308)
W/System.err: at com.parse.ParseRESTUserCommand.onResponseAsync(ParseRESTUserCommand.java:126)
W/System.err: at com.parse.ParseRequest.then(ParseRequest.java:137)
W/System.err: at com.parse.ParseRequest.then(ParseRequest.java:133)
W/System.err: at bolts.Task.run(Task.java:917)
W/System.err: at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
W/System.err: at bolts.Task.completeAfterTask(Task.java:908)
W/System.err: at bolts.Task.continueWithTask(Task.java:715)
W/System.err: at bolts.Task.continueWithTask(Task.java:726)
W/System.err: at bolts.Task.then(Task.java:818)
W/System.err: at bolts.Task.then(Task.java:806)
W/System.err: at bolts.Task.run(Task.java:917)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
W/System.err: at java.lang.Thread.run(Thread.java:762)
W/System.err: Caused by: org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
W/System.err: at org.json.JSON.typeMismatch(JSON.java:111)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:160)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:173)
W/System.err: at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:298)
W/System.err: ... 14 more
感谢您的宝贵时间。
将此添加到您的构建依赖项中:compile 'com.parse:parseinterceptors:0.0.2'
然后像这样初始化解析:
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId(appId)
.clientKey("")
.server(serverUrl)
.addNetworkInterceptor(new ParseLogInterceptor())
.build()
);
根据该日志输出,您可能会发现它正在使用错误的服务器 URL 或错误的应用程序 ID 进行初始化。如果没有,您将在日志中获得完整的 HTML 响应,这应该让您更好地了解发生了什么。
所以我正在尝试用 Parse 做一个项目,但我的开端真的很糟糕。 按照文档中的步骤进行操作后,我尝试执行任何请求(登录、对象创建),但在等待很长时间(总是超过 10-15 秒)后,我收到如下所示的错误:
com.parse.ParseRequest$ParseRequestException: bad json response
Caused by: org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
在浏览了所有存在的问题和答案后,我发现这种情况通常有两个原因:
初始化中的 link 是否缺少“/” 该应用程序没有连接
我已经通过调试排除了这两种可能性,但我仍然发现自己卡住了。 非常感谢此时的任何帮助。
这一行下面是完整的 Logcat 我有,前 3 行是我的日志,其余的是错误生成的。
E/error: bad json response
E/error code =: 100
E/error toString: com.parse.ParseRequest$ParseRequestException: bad json response
W/System.err: com.parse.ParseRequest$ParseRequestException: bad json response
W/System.err: at com.parse.ParseRequest.newTemporaryException(ParseRequest.java:290)
W/System.err: at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:308)
W/System.err: at com.parse.ParseRESTUserCommand.onResponseAsync(ParseRESTUserCommand.java:126)
W/System.err: at com.parse.ParseRequest.then(ParseRequest.java:137)
W/System.err: at com.parse.ParseRequest.then(ParseRequest.java:133)
W/System.err: at bolts.Task.run(Task.java:917)
W/System.err: at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
W/System.err: at bolts.Task.completeAfterTask(Task.java:908)
W/System.err: at bolts.Task.continueWithTask(Task.java:715)
W/System.err: at bolts.Task.continueWithTask(Task.java:726)
W/System.err: at bolts.Task.then(Task.java:818)
W/System.err: at bolts.Task.then(Task.java:806)
W/System.err: at bolts.Task.run(Task.java:917)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
W/System.err: at java.lang.Thread.run(Thread.java:762)
W/System.err: Caused by: org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
W/System.err: at org.json.JSON.typeMismatch(JSON.java:111)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:160)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:173)
W/System.err: at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:298)
W/System.err: ... 14 more
感谢您的宝贵时间。
将此添加到您的构建依赖项中:compile 'com.parse:parseinterceptors:0.0.2'
然后像这样初始化解析:
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId(appId)
.clientKey("")
.server(serverUrl)
.addNetworkInterceptor(new ParseLogInterceptor())
.build()
);
根据该日志输出,您可能会发现它正在使用错误的服务器 URL 或错误的应用程序 ID 进行初始化。如果没有,您将在日志中获得完整的 HTML 响应,这应该让您更好地了解发生了什么。