我正在使用“格子纸和床单” API将信用卡对帐单数据发送到Google床单。
我能够发送帐户,供应商名称,日期和金额,但似乎也无法在Google工作表中填充类别。
以下是我正在使用的数据的示例:
{"range":"A1:E1","values":[["creditcard","Peet\'s Coffee & Tea","2019-04-01",-2.3,["Food and Drink","Restaurants","Coffee Shop"]]]},
我尝试了以下两个选项。
不起作用(错误消息)
values: [Object.values(transaction)]
AND
values: [[transaction.account, transaction.name, transaction.date, transaction.amount, transaction.category ]]
WORKS(gsheets中的省略类别)
values: [[transaction.account, transaction.name, transaction.date, transaction.amount]]
FETCH
return rawTransactions.reduce((all, { account, transactions }) => {
return all.concat(transactions.map(({ name, date, amount, category }) => ({
account,
name,
date,
amount: -amount,
category
})))
}, [])
}
TRANSFORM
const updates = transactions.map(function(transaction, i) {
return {
range: `A${i + 2}:E${i + 2}`,
values: [[transaction.account, transaction.name, transaction.date, transaction.amount, transaction.category ]]
}
});
updates.push({
range: `A1:E1`,
values: [['Account', 'Name', 'Date', 'Amount', 'Category' ]]
})
我希望“值”中的所有数据都将发送到Google工作表,但出现以下错误消息。
data: { error: [Object] } },
code: 400,
errors:
[ { message:
'Invalid data[0]: Invalid values[1][4]: list_value {\n values {\n string_value: "Service"\n }\n values {\n string_value: "Advertising and Marketing"\n }\n values {\n string_value: "Online Advertising"\n }\n}\n',
domain: 'global',
reason: 'badRequest' } ] }