kintone RESTAPIで取得してきたJSONデータのレコードIDをbodyのidsにセットしましたが、配列に入っているものの形式が違うのか400エラーが出ます。取得してきたvalueデータを変換しなくてはならないのでしょうか。いろいろ試しましたが、検討がつきません。よろしくお願いします。
(function(){
“use strict”
var recid = [];
kintone.events.on(‘app.record.index.show’, function(event) {
var query = “Day < FROM_TODAY(-1,MONTHS)”;
var body = {
‘app’: kintone.app.getId(),
‘query’: query,
};
kintone.api(kintone.api.url(‘/k/v1/records’, true), ‘GET’, body, function(resp) {
// success
for(var i = 0; i < resp.records.length; i++) {
recid.push(JSON.parse(resp.records[i][‘レコード番号’].value));
//parseInt(resp.records[i][‘レコード番号’].value,10)
};
recid.map(id => id.textContent);
}, function(error) {
// error
console.log(error);
});
});
kintone.events.on(‘app.record.index.show’, function(event) {
var body2 = {
‘app’: kintone.app.getId(),
‘ids’: recid,
};
kintone.api(kintone.api.url(‘/k/v1/records.json’, true), ‘DELETE’, body2, function(resp) {
// success
console.log(resp);
}, function(error) {
// error
console.log(error);
});
return event;
});
})();