こちらの記事を参考にすべてコピーをして作成したのですがxml.openでエラー?警告?がでていて、
xml.onloadのfunctionにはいっていかないです。xml.statusはconsoleで確認した結果200だったのですがなにが原因でしょうか。ご存じの方お助けください。
(function() {
'use strict';
kintone.events.on('app.record.edit.submit', function(event) {
var blob = new Blob(['テストファイルです'], {
type: 'text/plain'
});
// FormDataにファイルを格納
var formData = new FormData();
formData.append(' __REQUEST_TOKEN__', kintone.getRequestToken());
formData.append('file', blob, 'test.txt');
var xmlHttp = new XMLHttpRequest();
xmlHttp.open('POST', kintone.api.url('/k/v1/file', true), false);
xmlHttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xmlHttp.send(formData);
xmlHttp.onload = function() {
if (xmlHttp.status === 200) {
var key = JSON.parse(xmlHttp.responseText).fileKey;
}
};
var json = {
app: kintone.app.getId(),
id: kintone.app.record.getId(),
record: {
file: {
value: [{fileKey: key}]
}
}
};
kintone.api(kintone.api.url('/k/v1/record', true), 'PUT', json);
});
})();