Skip to content

BulkRequest

The Bulk Request API allows multiple API requests to run on multiple kintone apps. The below API can be used with the Bulk Request API:

  • Add Record
  • Add Records
  • Update Record
  • Update Records
  • Delete Records
  • Update Status
  • Update Statuses
  • Update Assignees

Constructor

Parameter

Name Type Required Description
connection Connection yes The connection module of this SDK.

Sample code

Init bulk request module Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);

Methods

All below methods (excluded execute() method) will add request to queue, you must execute the execute() function to get result of BulkRequest.

addRecord(app, record)

Parameter

See at Record - addRecord

Return

BulkRequest

Sample code

add Record Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);
HashMap record = new HashMap();

Integer appID = 1;


FieldValue fv = new FieldValue();
fv.setType(FieldType.SINGLE_LINE_TEXT);
fv.setValue("sample_AddRecord");

record.put("FieldCode1", fv);

bulkRequestManager.addRecord(appID, record);

addRecords(app, records)

Parameter

See at Record - addRecords

Return

BulkRequest

Sample code

add multiple Records Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);
ArrayList> records = new ArrayList>();
HashMap record1 = new HashMap();
HashMap record2 = new HashMap();

Integer appID = 1;

FieldValue fv = new FieldValue();
fv.setType(FieldType.SINGLE_LINE_TEXT);
fv.setValue("sample_AddRecords1");

FieldValue fv2 = new FieldValue();
fv2.setType(FieldType.SINGLE_LINE_TEXT);
fv2.setValue("sample_AddRecords2");

record1.put("FieldCode1", fv);
record2.put("FieldCode1", fv2);

records.add(record1);
records.add(record2);

bulkRequestManager.addRecords(appID, records);

updateRecordByID(app, id, record, revision)

Parameter

See at Record - updateRecordByID

Return

BulkRequest

Sample code

update Record By ID Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);
HashMap record = new HashMap();

Integer appID = 1;
Integer recordID = 1;
Integer revision = 1;

FieldValue fv = new FieldValue();
fv.setType(FieldType.SINGLE_LINE_TEXT);
fv.setValue("sample_updateRecordById");

record.put("FieldCode1", fv);

bulkRequestManager.updateRecordByID(appID, recordID, record, revision);

updateRecordByUpdateKey(app, updateKey, record, revision)

Parameter

See at Record - updateRecordByUpdateKey

Return

BulkRequest

Sample code

update Record By UpdateKey Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);
HashMap record = new HashMap();
RecordUpdateKey uKey = new RecordUpdateKey("文字列__1行__0", "unique_value1");

Integer appID = 1;
Integer revision = 1;

FieldValue fv = new FieldValue();
fv.setType(FieldType.SINGLE_LINE_TEXT);
fv.setValue("sample_updateRecordByUpdateKey");

record.put("FieldCode1", fv);

bulkRequestManager.updateRecordByUpdateKey(appID, uKey, record, revision);

updateRecords(app, records)

Parameter

See at Record - updateRecords

Return

BulkRequest

Sample code

update multiple Records Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);
HashMap record1 = new HashMap();
HashMap record2 = new HashMap();

Integer appID = 1;
Integer recordId1 = 1;
Integer recordId2 = 2;
Integer revision = 1;

FieldValue fv1 = new FieldValue();
fv1.setType(FieldType.SINGLE_LINE_TEXT);
fv1.setValue("test_updateRecords1");

FieldValue fv2 = new FieldValue();
fv2.setType(FieldType.SINGLE_LINE_TEXT);
fv2.setValue("test_updateRecords2");

record1.put("FieldCode1", fv1);
record2.put("FieldCode1", fv2);

ArrayList records = new ArrayList();
records.add(new RecordUpdateItem(recordId1, revision, null, record1));
records.add(new RecordUpdateItem(recordId2, null, null, record2));

bulkRequestManager.updateRecords(appID, records);

deleteRecords(app, ids)

Parameter

See at Record - deleteRecords

Return

BulkRequest

Sample code

Bulk Delete Records Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);

Integer appID = 1;

ArrayList ids = new ArrayList();
ids.add(1);
ids.add(2);


bulkRequestManager.deleteRecords(appID, ids);

deleteRecordsWithRevision(app, idsWithRevision)

Parameter

See at Record - deleteRecordsWithRevision

Return

BulkRequest

Sample code

delete Records With Revision Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);
HashMap idsWithRevision = new HashMap();

Integer appID = 1;

idsWithRevision.put(1, 1);
idsWithRevision.put(2, null);
idsWithRevision.put(3, -1);

bulkRequestManager.deleteRecordsWithRevision(appID, idsWithRevision);

updateRecordAssignees(app, record, assignees, revision)

Parameter

See at Record - updateRecordAssignees

Return

BulkRequest

Sample code

Update the Assignees for the record Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);

Integer appID = 1;
Integer recordID =1;
Integer revision = 1;

ArrayList assignees = new ArrayList();
assignees.add("sample_user");

bulkRequestManager.updateRecordAssignees(appID, recordID, assignees, revision);

updateRecordStatus(app, id, action, assignee, revision)

Parameter

See at Record - updateRecordStatus

Return

BulkRequest

Sample code

Update the status of a single record Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);

Integer appID = 1;
Integer recordID =1;
String action = "処理開始";
String assignee = "sample_user";
Integer revision = 1;

bulkRequestManager.updateRecordStatus(appID, recordID, action, assignee, revision);

updateRecordsStatus(app, records)

Parameter

See at Record - updateRecordsStatus

Return

BulkRequest

Sample code

Update the status of multiple records in bulk Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);
ArrayList rusi = new ArrayList();

Integer appID = 1;
String action = "処理開始";
String assignee = "sample_user1";
Integer recordID1 =1;
Integer recordID2 =2;
Integer recordID3 =3;
Integer revision1 = 1;
Integer revision2 = null;
Integer revision3 = -1;

rusi.add(new RecordUpdateStatusItem(action, assignee, recordID1, revision1));
rusi.add(new RecordUpdateStatusItem(action, assignee, recordID2, revision2));
rusi.add(new RecordUpdateStatusItem(action, assignee, recordID3, revision3));

bulkRequestManager.updateRecordsStatus(appID, rusi);

execute()

Execute the bulk request and get data response

Parameter

(none)

Return

BulkRequestResponse

Sample code

Execute bulk request Source code
BulkRequest bulkRequestManager = new BulkRequest(connection);
bulkRequestManager.addRecord(/*[Args]*/);
bulkRequestManager.addRecords(/*[Args]*/);
bulkRequestManager.updateRecords(/*[Args]*/);
bulkRequestManager.deleteRecords(/*[Args]*/);

try {
  BulkRequestResponse responses = bulkRequestManager.execute();
} catch (Exception e) {
  System.out.println(e.getMessage());
}

Reference