objectId
我通过按属性搜索,将字节转换为字符串,然后从结果中获取值,从带有 REST 调用的表中检索条目。
new_requests = Popen(['curl',
'-H', 'application-id: %s' % backendless_appid,
'-H', 'secret-key: %s' % backendless_sk,
'-H', 'Content-Type: application/json',
'-X', 'GET',
'-v', 'https://api.backendless.com/v1/data/Request?where=requestId%3D1'],
stdout=PIPE).communicate()[0]
new_requests_str = new_requests.decode(encoding='utf-8')
new_requests_objectid = json.loads(new_requests_str, strict=False)['objectId']
不幸的是,这导致KeyError: 'objectId'
print(new_requests_str)
返回 JSON 结果,所以问题是new_requests_objectid
.
{"offset":0,"data":[{"emailAddress":"eric@apakau.com","apiEndpoint":"http://www.yahoo.com","created":1438986033000,"requestId":"1","___class":"Request","ownerId":null,"updated":1439222409000,"objectId":"723B5AEE-5D60-E00E-FF92-ACA3B4629F00","apiSecretkey":"asdfasa","__meta":"{\"relationRemovalIds\":{},\"selectedProperties\":[\"emailAddress\",\"apiEndpoint\",\"created\",\"requestId\",\"___class\",\"ownerId\",\"updated\",\"objectId\",\"apiSecretkey\"],\"relatedObjects\":{}}"}],"nextPage":null,"totalObjects":1}