Skip to main content

ImportItems

CSV data Import

Description

Specify the CSV file and update the database (datastore). It is possible to create, update, and delete.

  • If the same value exists in the field specified as the key field, it will be updated, and if it does not exist, it will be newly registered.
  • If the replace_all(bool) option is set to true, all data will be deleted and newly registered (replaced) with the specified CSV data. Compared to the case where the option is not specified, processing is faster.
  • If the append (bool) option is set to "true", the specified CSV data will be registered with the existing data. Processes more quickly than when not specified.
  • Prepare a delete field (item name as _delete_) in the CSV and specify true or 1 for the Item to be deleted, and the corresponding Item will be deleted.
  • The field meaning status in the CSV has the CSV header name as _status_ and the status name (not status_id) in the data.
  • If you prepare a public group designation field (item name as _group_id_) in CSV and specify a group ID defined from the screen in Hexabase in the CSV data, the corresponding Item will be published to the specified group. (A group access key will be assigned.)

Method

POST

Request URL Format

/api/v0/applications/:app-id/datastores/:datastore-id/import

URL Params

app-id    : Application ID (application ID specified from the screen, or p_id)
datastore-id : Datastore ID (Datastore ID specified from the screen, or d_id)

Content-Type : multipart/form-data

filename            : Import data file name
file : Import file
key_field_displayid : Specify the field ID to be used as the key item of the import destination data store (update using this column as the key)

replace_all : false | true Initialize data with specified CSV (delete all data and add new)
append : false | true Appends the specified CSV data to the existing data. Separately, data can be differentially deleted & additionally imported by executing in sequence with the `Delete API with specified conditions`.
no_queue : false | true Immediately imports the specified CSV data without putting it into the Queue. 100 or less data can be immediately executed.
overwrite_autonumber: false | true The auto-numbering items at the import destination are initialized and imported with a zero start.
validate : true | false Omit data check on import.

Request Sample

POST https://api.xxx.com/api/v0/applications/APP-ID/datastores/DATABASE-ID/import

CSV File Image

  • The CSV header line specifies the field ID specified from the screen
  • When using the key_field_displayid update, you can use a CSV that omits columns other than the key field and the field to be updated. (It is not necessary to include all fields in the database.)
TITLE,_status_,Field1,No,_delete_
import1,ステータス1,A,001,0
import2,ステータス2,B,002,0

Response

  • If no_queue is not specified or false

    {
    "temp_datastore_id": "5e58aa0fe4ecac3bd828aead",
    "stream_id": "saXjPYrkoJULrJTXHystqbXBqmUkILVbbBxvyXNsiJXKUdcROfTQOwGwCo6nqkwDDGjnUeiPtdkjkDeqgjquUOmcl0B6aM9q2V5526y2Xn3XmPZFsBSrooAwqTSAjWYr"
    }
    temp_datastore_id : ID available for obtaining data import results (not available for GetImportResults if append or replace_all is specified as true)
    stream_id : ID to subscribe to import progress

    ※ The Subscribe specification is not included in this document (currently in preparation)

  • If no_queue is true

    Success

    {
    "errors": [],
    "has_error": false,
    "result": {
    "imported": 4,
    "item_count": 4
    }
    }

    on error

    {
    "errors": [
    {
    "description": "the number of imports exceeds the limit. please set the no_queue flag to false.",
    "error": "too many items",
    "error_level": "ERROR"
    }
    ],
    "has_error": true,
    "result": {
    "imported": 0,
    "item_count": 104
    }
    }
    imported : Number of imports processed
    item_count : Number of target imports