我有一个主要问题,并希望有人可以提供帮助。Parse.com REST API不会返回任何东西
我们有使用Parse作为后端的web和Android应用程序。我们遇到的问题都发生在两者上。我会解释Android的问题。
我们使用REST API将数据保存到Parse.com。我们不使用SDK的原因是我们想要利用仅在RESTAPI中可用的批处理操作。
{
"requests": [
{
"body": {
"isFriable": false,
"haDetail": "",
"sizeOther": "",
"colourOther": "",
"texture": "",
"fieldInspection": {
"__type": "Pointer",
"className": "FieldInspection",
"objectId": "YS5bXHBwDu"
},
"surfaceSubType": {
"__type": "Pointer",
"className": "SurfaceSubType",
"objectId": "d4IL5k1pv5"
},
"size": {
"__type": "Pointer",
"className": "HomogenousMaterialSize",
"objectId": "ezr3uHDUvt"
},
"colour": {
"__type": "Pointer",
"className": "HomogenousMaterialColour",
"objectId": "NqYXJcOkPE"
}
},
"method": "POST",
"path": "/1/classes/HomogenousArea"
}
]
}
以上是我的要求。这被推到https://api.parse.com/1/batch使用一个基本的默认HttpClient。
当我们执行HTTP请求时,它有时会挂起,它不会返回任何结果。大约每5或6个请求中就有一个这样做。在成功的后续请求上完全相同的数据将会通过罚款。问题是,那时我们有重复的记录保存到Parse,因为我们的同步逻辑从未完成,因为我们没有得到响应。
Parse中有什么我们可以用来调试这样的请求吗?以下是我们正在使用的当前http客户端实现。注意:也放在从Square的OkHttp并击中完全相同的问题。在./batch的
// Instantiate the http client to make the batch request
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost post = setupHttpPost(url);
// Assign the data to the post
StringEntity entity = new StringEntity(insertData);
post.setEntity(entity);
// Setup the response handler
ResponseHandler response = new BasicResponseHandler();
// Make the call to Post the new data
Object rersponse = httpClient.execute(post, response);
if (rersponse != null) {
return rersponse.toString();
}
return null;
感谢您的回复罗伯特。 outter调用方法包装在AsyncTask中,因此网络操作不会阻塞UI线程。我也减少了请求中的数据量,但仍然相同。我的下一个端口是发送直接,但我怀疑我不会看到任何错误,因为它的工作很直接 – 2014-10-08 15:10:49
我会钻AsnycTask,这就是你的问题所在。 – 2014-10-08 15:50:48
我已经遵循该路径。会让你知道结果。再次感谢您的快速回复 – 2014-10-08 16:11:00