我按照这些说明运行了 setupdemo 事务(它只是添加了一些示例数据),并成功地添加了一个加速度计读数,该读数针对现有的货物到区块链。装运数据包含加速度计读数:
{
"$class": "org.acme.shipping.perishable.Shipment",
"shipmentId": "320022000251363131363432",
"type": "MEDICINE",
"status": "IN_TRANSIT",
"unitCount": 5000,
"contract": "resource:org.acme.shipping.perishable.Contract#CON_002",
"AccelReadings": [
{
"$class": "org.acme.shipping.perishable.AccelReading",
"accel_x": 4,
"accel_y": 4,
"accel_z": 4,
"latitude": "51",
"longitude": "11",
"readingTime": "2018-11-21T19:40:30.000Z",
"shipment": "resource:org.acme.shipping.perishable.Shipment#320022000251363131363432",
"transactionId": "01aed2c05c78cf638cc68e9bb4ab7428dc7bae212c6409c27049c372f5caee67",
"timestamp": "2018-11-21T18:45:42.497Z"
}
]
}
但是,我在运行 GET /AccelReading 的资源管理器中遇到错误。
{
"error": {
"statusCode": 500,
"name": "ValidationException",
"message": "Unexpected properties for type org.acme.shipping.perishable.AccelReading: accel_x, accel_y, accel_z, latitude, longitude, readingTime",
"stack": "ValidationException: Unexpected properties for type org.acme.shipping.perishable.AccelReading: accel_x, accel_y, accel_z, latitude, longitude, readingTime\n at validateProperties (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:60:15)\n at JSONPopulator.visitClassDeclaration (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:118:9)\n at JSONPopulator.visit (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:96:25)\n at TransactionDeclaration.accept (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/introspect/decorated.js:65:24)\n at Serializer.fromJSON (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer.js:180:26)\n at resources.map (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-client/lib/registry.js:302:44)\n at Array.map (<anonymous>)\n at Util.queryChainCode.then.then (/home/asset-tracker/.nvm/versions/node/v8.13.0/lib/node_modules/composer-rest-server/node_modules/composer-client/lib/registry.js:301:34)\n at <anonymous>"
}
}