У меня есть API, который получает это JSON:
{
"name": "Mar/19",
"month": "3",
"year": "2019",
"credit": [
{
"name": "Income salary",
"value": "6500"
}
],
"debit": [
{
"name": "Rent",
"value": "2500"
}
]
}
И мой бэкэнд работает на AWS и должен поместить эту информацию в таблицу DynamoDB. Лямбда-функция выглядит следующим образом:
const params = {
Item: {
"id": {
S: ""+Math.random()
},
"name": {
S: event.name
},
"month": {
N: event.month
},
"year": {
N: event.year
},
},
TableName: "billing-circle"
};
dynamodb.putItem(params, function(err, data){
if(err) {
console.log(err);
callback(err);
} else {
console.log(data);
callback(null, data);
}
});
API имеет шаблон сопоставления, объявленный в запросе на интеграцию, и выглядит следующим образом:
#set($inputRoot = $input.path('$'))
{
"name" : "$inputRoot.name",
"month" : "$inputRoot.month",
"year" : "$inputRoot.year",
"credit" : [
#foreach($elem in $inputRoot.credit)
{
"name" : "$elem.name",
"value" : "$elem.value"
}
#if($foreach.hasNext),#end
#end
],
"debit" : [
#foreach($elemDebit in $inputRoot.debit)
{
"name" : "$elemDebit.name",
"value" : "$elemDebit.value",
"status" : "$elemDebit.status"
}
#if($foreach.hasNext),#end
#end
]
}
Я пытаюсь вызвать API из Почтальона, но Я получил эту ошибку:
{
"errorType": "ValidationException",
"errorMessage": "Supplied AttributeValue is empty, must contain exactly one of the supported datatypes",
"trace": [
"ValidationException: Supplied AttributeValue is empty, must contain exactly one of the supported datatypes",
" at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:51:27)",
" at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)",
" at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)",
" at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)",
" at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
" at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
" at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
" at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
" at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)",
" at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18)"
]
}
Кто-нибудь может мне помочь с этим?