アプリID 1、既存レコードID 1 の「comment」項目を更新するコードを GAS で書きました。 (実際にはサブドメインを設定しています)
function test_update_record() {
const app = 1;
const id = 1;
const api_token = PropertiesService.getScriptProperties().getProperty('API_TOKEN');
const url = 'https://xxxxx.cybozu.com/k/v1/record.json';
const headers = {
'Content-Type':'application/json',
'X-Cybozu-API-Token': api_token
};
const api_query = {
'app': app,
'id': id,
'record': {
'comment': {'value': 'テストコメント'}
}
};
const options = {
'method' : 'post',
"headers" : headers,
'payload' : JSON.stringify(api_query)
};
const response = UrlFetchApp.fetch(url, options);
const content = response.getContentText('UTF-8');
const json = JSON.parse(content);
}
こちらを実行したところ、以下のエラーとなりました。
Exception: Request failed for https://vs4yn.cybozu.com returned code 400. Truncated server response: {“code”:“CB_VA01”,“id”:“iFvds0uDMMvjpXZeBffn”,“message”:“入力内容が正しくありません。”,“errors”:{“record.チェックボックス_4.values”:{“messages”:[“必須です。”]},"record.件名.val…
チェックボックス_4 となっている項目は確かに必須項目なのですが、レコード1 では既にチェック済になっていますし、手作業でレコードを更新する場合には「comment」項目のみ変更して保存可能な状態となっており、動作が「更新」ではなく「新規登録」のようになってしまっているのかなと想像しているのですが、原因が分からずにおります。
ありえそうな原因についてアドバイスをいただけますと大変助かります。