Haan Mo Johng, Ph.D. Candidate at UT Dallas, imaginejhm@gmail.com
PostList
2018년 8월 13일 월요일
Invalid JSON data. Found a value that is not a string
Problem:
When POST with a JSON parameter of
{
"$class": "test.SampleAsset",
"assetId": "ID-2",
"owner": {},
"value": "3000"
}
The error below appears
{ "error": { "statusCode": 500, "name": "Error", "message": "Invalid JSON data. Found a value that is not a string: [object Object] for relationship RelationshipDeclaration {name=owner, type=test.SampleParticipant, array=false, optional=false}", "stack": "Error: Invalid JSON data. Found a value that is not a string: [object Object] for relationship RelationshipDeclaration {name=owner, type=test.SampleParticipant, array=false, optional=false}\n at JSONPopulator.visitRelationshipDeclaration (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:249:27)\n at JSONPopulator.visit (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:58:25)\n at RelationshipDeclaration.accept (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/introspect/decorated.js:54:24)\n at JSONPopulator.visitClassDeclaration (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:83:60)\n at JSONPopulator.visit (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:56:25)\n at AssetDeclaration.accept (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/introspect/decorated.js:54:24)\n at Serializer.fromJSON (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer.js:189:26)\n at ensureConnected.then (/usr/local/lib/node_modules/composer-rest-server/node_modules/loopback-connector-composer/lib/businessnetworkconnector.js:634:43)\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:188:7)" } }
Solution:
1. Assign owner value like,
{
"$class": "test.SampleAsset",
"assetId": "ID-2",
"owner": "O-1",
"value": "3000"
}
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기