简体   繁体   中英

Android Parse Platform ParseRequestException: bad json response

So I'm trying to do a project with Parse, and I'm off to a really bad start. After following the steps on the documentation, I try to do any request (login, object creation) and after a long time waiting (always over 10-15 seconds) I get an error that looks like this:

com.parse.ParseRequest$ParseRequestException: bad json response

Caused by: org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject

After browing all existent questions and answers I found out this happens usually from two reasons:

Either the link from the initilization is missing a " / " Either the app has no connectivity

I have eliminated both of this possibilities thru my debugging and I still find myself stuck. Any help at this point is much appreciated.

Below this line is the full Logcat I have, the first 3 lines being my logs and the rest the ones generated by the error.


 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$3.then(ParseRequest.java:137)
 W/System.err:     at com.parse.ParseRequest$3.then(ParseRequest.java:133)
 W/System.err:     at bolts.Task$15.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$13.then(Task.java:818)
 W/System.err:     at bolts.Task$13.then(Task.java:806)
 W/System.err:     at bolts.Task$15.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

Thank you for your time.

Add this to your build dependencies: compile 'com.parse:parseinterceptors:0.0.2'

and then initialize parse like this:

Parse.initialize(new Parse.Configuration.Builder(this)
                .applicationId(appId)
                .clientKey("")
                .server(serverUrl)
                .addNetworkInterceptor(new ParseLogInterceptor())
                .build()
        );

With that log output, you'll probably find it's initializing with either the wrong server URL or the wrong app id. If not, you will get the full HTML response in the log and that should give you a better idea what's going on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM