gpt4 book ai didi

android - 解析服务器错误的 json 响应错误代码 100

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:35:42 26 4
gpt4 key购买 nike

我正在使用这个 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 中使用 curl 就完美了

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/")

关于android - 解析服务器错误的 json 响应错误代码 100,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35371307/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com