[英]AWS DynamoDB issue with PutItem. What's the proper JSON format?
我在將PutItem請求發送到DynamoDB時遇到問題。 我知道這里已經回答了類似的問題,但似乎我這里沒有空值。
我的JSON是:
{
"TableName":"Unity",
"Item":{
"id":{
"S":"73709359-ac78-46a0-8ca6-414393e33339"
},
"Session":{
"S":"b6ba8b6d-ce27-4585-aee5-b9a2393e54da"
},
"Pos":{
"X":{
"S":"-16.8"
},
"Y":{
"S":"-4.492812"
}
},
"Time":{
"S":"7/27/2017 3:21:25 PM"
}
}
}
錯誤是ValidationException:
Supplied AttributeValue is empty, must contain exactly one of the supported datatypes
有人知道發生了什么嗎?
請嘗試以下代碼。 我為屬性Pos
添加了數據類型Map 。
var dynamoDB = new AWS.DynamoDB;
var params = {
TableName: "Unity",
Item: {
"id": {
S: "73709359-ac78-46a0-8ca6-414393e33339"
},
"Session": {
S: "b6ba8b6d-ce27-4585-aee5-b9a2393e54da"
},
"Pos": {
M: {
"X": {
S: "-16.8"
},
"Y": {
S: "-4.492812"
}
}
},
"Time": {
S: "7/27/2017 3:21:25 PM"
}
}
};
console.log("Adding a new item...");
dynamoDB.putItem(params, function (err, data) {
if (err) {
console.error("Unable to add item. Error JSON:", JSON.stringify(err,
null, 2));
} else {
console.log("Added item:", JSON.stringify(data, null, 2));
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.