失敗するパターン
オブジェクトの配列をそのままpayloadにセット
const reqOptions = {
method: 'post',
payload: [{sample: 1}, {sample: 2}]
}
const res = UrlFetchApp.fetch(Config.API.URL, reqOptions);
単純なJSON.stringify
const reqOptions = {
method: 'post',
payload: JSON.stringify([{sample: 1} {sample: 2}])
}
const res = UrlFetchApp.fetch('https://xxx', reqOptions);
成功するパターン
contentType: 'application/json'
をセットする
const reqOptions = {
method: 'post',
contentType: 'application/json', // これ!!!
payload: JSON.stringify([{sample: 1} {sample: 2}])
}
const res = UrlFetchApp.fetch('https://xxx', reqOptions);