android – Parse Server坏json响应错误代码100

我使用这个Parse Server Guide来创建一个解析服务器的本地实例.我下载并设置了示例并且运行完美,但是当我尝试使用android SDK时,我收到此错误

02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens 

W/System.err﹕ com.parse.ParseRequest$ParseRequestException: bad json response
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at com.parse.ParseRequest.newTemporaryException(ParseRequest.java:290)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:308)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at com.parse.ParseRequest$3.then(ParseRequest.java:137)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at com.parse.ParseRequest$3.then(ParseRequest.java:133)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task$15.run(Task.java:917)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task.completeAfterTask(Task.java:908)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task.continueWithTask(Task.java:715)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task.continueWithTask(Task.java:726)
02-12 22:41:58.674    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task$13.then(Task.java:818)
02-12 22:41:58.674    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task$13.then(Task.java:806)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task$15.run(Task.java:917)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at java.lang.Thread.run(Thread.java:841)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ Caused by: org.json.JSONException: Value Cannot of type java.lang.String cannot be converted to JSONObject
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at org.json.JSON.typeMismatch(JSON.java:111)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at org.json.JSONObject.<init>(JSONObject.java:159)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at org.json.JSONObject.<init>(JSONObject.java:172)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:298)
02-12 22:41:58.690    7211-7211/com.christoandrew.android.authens W/System.err﹕ ... 13 more

这是我的index.js

    // Example express application adding the parse-server module to expose Parse
// compatible API routes.

var express = require('express');
var ParseServer = require('parse-server').ParseServer;

var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI

if (!databaseUri) {
  console.log('DATABASE_URI not specified, falling back to localhost.');
}

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/authens',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'UBXrCTUXuXf6fEBpbE7sHBamq4b0RdQcASFTHxo9',
  masterKey: process.env.MASTER_KEY || 'ghFiFWGtdymY3oXqWDTDBz6RyW7XdMyWzjXoJjFb', //Add your master key here. Keep it secret!
  clientKey: '4m2WpkkGCX77w3FNq3JWT74nVgRKNsgTj10Q1s4t',
  //restAPIKey: 'b7gUiB4cI7JeKLqKCWCkTZbBX4YA9S7xlQuwmUqX',
  //javascriptKey: '0qBhikhxV8ZtM95o1zTLFhhiuuLGiwDVcTxyvNdw',
 // dotNetKey: 'rc0uYDFU3Bo5U24PlBxKMBX7GpsHj8QHJLLVgsFg',
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey

var app = express();

// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
  res.status(200).send('I dream of being a web site.');
});

var port = process.env.PORT || 1337;
app.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});

这是我初始化的方式

Parse.enableLocalDatastore(this);
    Parse.initialize(new Parse.Configuration.Builder(this)
            .applicationId(getString(R.string.parse_app_id))
            .clientKey(getString(R.string.parse_client_key))
            .server("http://10.0.3.2:1337/parse")
            .build());
    Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);

在教程中.我使用genymotion作为运行在10.0.3.2的虚拟设备.我有什么遗漏或这是一个普遍的问题.

更新

如果我使用cmd从cmd工作完美

curl -X POST -H "X-Parse-Application-Id: UBXrCTUXuXf6fEBpbE7sHBamq4b0RdQcASFTHxo9" -H "X-Parse-Client-Key: 4m2WpkkGCX77w3FNq3JWT74nVgRKNsgTj10Q1s4t" -H "Content-Type: application/json" -d @json.txt http://localhost:1337/parse/classes/GameScore

解决方法:

我找到了解决方案.
而不是这个

.server("http://10.0.3.2:1337/parse")

用这个

.server("http://10.0.3.2:1337/parse/")
上一篇:peewee-async集成到tornado


下一篇:peewee基本使用