ExecuteBatchAction
Execute multiple Item actions
Description
- Execute actions in the same application in batch.
- "ensure_transaction": true can be specified to process as one transaction (rollback in case of error). (However, the ActionScript execution code is not included in the same transaction.)
- New, update, or delete actions are executed in order, but the execution order is not guaranteed.
- Pre-ActionScript in each action is not executed.
Method
POST
Request URL Format
/api/v0/applications/:app-id/BatchAction
Payload
Content-Type : application/json
{
"ensure_transaction": true, // If true, all registrations will be rolled back if even one error occurs during the processing of a related item. The default is false, which means that successful related_item registrations and updates will be reflected, and error messages will be returned for details that have errors.
"item_actions" : { // For each data store, specify the action as an array.
"DATASTORE_A" : [
{
"operation" : 1, // new
"action_id" : "", // new actionID ※Optional (if omitted, the default new action is used)
"item": {
"FIELD_ID1" : "data",
"FIELD_ID2" : "data",
"FIELD_ID3" : "data",
"FIELD_ID4" : "data",
},
"access_key_updates": { // Specify access key for each item
"overwrite": true, // Overwrite and save the access key (default is false: append to the existing key)
"ignore_action_settings": true, // Do not use the public settings set in the action (only the key specified in this payload is given)
"apply_related_ds": true, // Use the same settings for items specified in related_ds_items
"groups_to_publish": ["GROUP1", "GROUP2"], // Specify group display_id (only keys held by the execution user can be specified)
"roles_to_publish": ["ADMIN", "MEMBER"], // Specify role display_id (only keys held by the execution user can be specified)
"users_to_publish": ["607c2a25844887b6855a12a9", "5f25956428dc5c55b463bc77" ] // Specify user_id (user_id existing in workspace can be specified)
},
"as_params": {"param1": "value1", "param2": "value2",}, // Any object (any type of format) can be passed to ActionScript. Passed to both the PRE/POST ActionScript. From within ActionScript it can be referenced as `data.as_params`.
"related_ds_items" : { // related_ds_items can also be nested. (Multiple nesting of the same Datastore is not allowed.)
"関連データストア_A" : [{ },{ },{ },{ }... ] ,
"関連データストア_B" : [{ },{ },{ },{ }... ] ,
}
},{
"operation" : 2, // update
"action_id" : "Update2", // update actionID * can be omitted (if omitted, the default update action will be used)
"i_id" : "58bbaa27fbfcba609874aaa3f", // Target item ID
"item": {
"FIELD_ID1" : "data",
"FIELD_ID3" : "data"
}
},{
"operation" : 3, // delete
"i_id" : "58bbaa27fbfcba609874aqr45", // Target item ID
},{
// Multiple actions can be specified. sample omitted
},{
// Multiple actions can be specified. sample omitted
}
],
"DATASTORE_B" : [
{
// sample Omitted
},{
// sample Omitted
},
],
"DATASTORE_C" : [
{
// sample Omitted
},{
// sample Omitted
},
]
},
"realtime_auto_link": true, // If true, run auto_link creation synchronously(processing will be slightly slower because of synchronous execution).
"access_key_updates": { // Specify an access key for the entire item
"overwrite": true, // Overwrite and save the access key (default is false: append to the existing key)
"ignore_action_settings": true, // Do not use the public settings set in the action (only the key specified in this payload is given)
"apply_related_ds": true, // Use the same settings for items specified in related_ds_items
"groups_to_publish": ["GROUP1", "GROUP2"], // Specify group display_id (only keys held by the execution user can be specified)
"roles_to_publish": ["ADMIN", "MEMBER"], // Specify role display_id (only keys held by execution user can be specified)
"users_to_publish": ["607c2a25844887b6855a12a9", "5f25956428dc5c55b463bc77" ] // Specify user_id (user_id existing in workspace can be specified)
},
"exec_children_post_procs": true, // If true is specified, ActionScript (POST ActionScript), Webhook execution, automatic link generation, and notification processing will also be performed for related_ds_items. Note: PRE ActionScript is not executed for related_ds_items.
}
Request URL Sample
POST https://api.xxx.com/api/v0/applications/TestApp/BatchAction
Response Sample
// Success
{
"result": {
"datastores": 1, // Number of target data stores
"items": 3 // Number of ItemActions processed
},
"has_error": false,
"errors": []
}
// In case of error (no transaction specified: out of 3 cases, 1 was an error, 2 were processed)
{
"errors": [
{
"description": "item:601a572c28dc5c4e8c0783cd(d_id:5f263b7628dc5c6af0b1206a) has rev_no:4 but specified rev_no:2",
"error": "Revision number mismatch",
"error_code": "ITEM_REV_CONFLICT", // Exclusion error
"error_level": "ERROR",
"reference_id": "601a572c28dc5c4e8c0783cd" // Target ItemID at the time of exclusion error
},
{
"description": "error occurred when execute action",
"error": "Error",
"error_code": "SYSTEM_ERROR",
"error_level": "ERROR",
"reference_id": "5c6a674f84f4be1f241ff4af" // Error target ItemID
}
],
"has_error": true,
"result": {
"datastores": 1,
"items": 2
}
}
// Error example (with transaction specified)
{
"description": "got errors when updating. AppName ",
"error": [
{
"description": "need rev_no to update ds:6121fccd27ef72f577ad28bc i:61e2f194f19fe200d9a95899 ",
"error": "rev_no not specified",
"error_code": "INVALID_VALUE",
"error_level": "ERROR",
"reference_id": "d_id:6121fccd27ef72f577ad28bc"
},
{
"description": "error on execute related item",
"error": "invalid params or got errors in update process",
"error_code": "TRANSACTION_ABORTED",
"error_level": "ERROR"
}
],
"error_code": "INVALID_VALUE"
}