我从parse.com迁移到托管的ParseSever。大多数事情都有效,但我发现对于一个类,字段不会更新。 HTTP请求在日志中返回200,在Python中,updatedAt字段显示最近的时间戳,但字段不会更改。在下面的python代码及其打印输出中,字段field1和field2继续显示旧值,即使在updatedAt和HTTP响应检出时也是如此。从REST API更新到其他类通常是有效的(没有详尽检查)。 SDK的更新正在运行。在parse.com上完美运行。类和条目的ACL是公共的。
def updateObjectWithId(self,objectId, objectJson):
self.connection.connect()
if(objectId == ""):
self.connection.request('POST','/parse/classes/'+self._className,objectJson,
{
"X-Parse-Application-Id": self.appId,
"X-Parse-Master-Key": self.masterApiKey
})
else:
print "ParseArchiver.updateObjectWithId: id: ", objectId, " of Class: ", self._className, " with json: ", objectJson
self.connection.request('PUT','/parse/classes/'+self._className+'/'+objectId,objectJson,
{
"X-Parse-Application-Id": self.appId,
"X-Parse-Master-Key": self.masterApiKey
})
result = json.loads(self.connection.getresponse().read())
time.sleep(ParseArchiver.ParseSleepTime)
print "*** ParseArchiver.updateObjectWithId: Result object is:",result
return
输出:
PredictionObject.write(): updating existing object with ID: On6AdEnPVb
ParseArchiver.updateObjectWithId: id: correct_id of Class: correct_class with json: {"field1": ["2016-06-07T22:00:00.000Z|0.267835319042|-0700", "2016-06-08T10:00:00.000Z|0.446276366711|-0700", "2016-06-08T22:00:00.000Z|0.778348565102|-0700", "2016-06-09T10:00:00.000Z|0.00348118506372|-0700", "2016-06-09T22:00:00.000Z|0.0183897037059|-0700", "2016-06-10T10:00:00.000Z|0.562650620937|-0700", "2016-06-10T22:00:00.000Z|0.079613097012|-0700", "2016-06-11T10:00:00.000Z|0.562650620937|-0700", "2016-06-11T22:00:00.000Z|0.0199579093605|-0700", "2016-06-12T10:00:00.000Z|0.629606068134|-0700", "2016-06-12T22:00:00.000Z|0.292343884706|-0700", "2016-06-13T10:00:00.000Z|0.0342484489083|-0700", "2016-06-13T22:00:00.000Z|0.0746899694204|-0700", "2016-06-14T10:00:00.000Z|0.0594595149159|-0700", "2016-06-14T22:00:00.000Z|0.424203515053|-0700", "2016-06-15T10:00:00.000Z|0.0349752865732|-0700", "2016-06-15T22:00:00.000Z|0.00455725379288|-0700", "2016-06-16T10:00:00.000Z|0.0987700968981|-0700", "2016-06-16T22:00:00.000Z|0.30742970109|-0700", "2016-06-17T10:00:00.000Z|0.0781866833568|-0700", "2016-06-17T22:00:00.000Z|0.367497861385|-0700", "2016-06-18T10:00:00.000Z|0.225806906819|-0700", "2016-06-18T22:00:00.000Z|0.0179004631937|-0700", "2016-06-19T10:00:00.000Z|0.11387591809|-0700", "2016-06-19T22:00:00.000Z|0.103792026639|-0700", "2016-06-20T10:00:00.000Z|0.710064172745|-0700", "2016-06-20T22:00:00.000Z|0.728509664536|-0700", "2016-06-22T10:00:00.000Z|0.140641510487|-0700"], "uid": "correct_uid", "field2": ["2016-06-20T22:00:00.000Z|0.728509664536|-0700", "2016-06-22T10:00:00.000Z|0.140641510487|-0700"]}
*** ParseArchiver.updateObjectWithId: Result object is: {u'updatedAt': u'2016-06-22T16:38:55.690Z'}
答案 0 :(得分:0)
我发现每个非GET请求现在必须有一个“Content-Type”字段。这在parse.com上不是必需的。我想可能是ParseServer可以设置一个默认的内容类型,允许一个省略这个参数,然后旧的代码将无需修改。修改后的工作代码段如下:
abc