Import to Data Tables
ImportToDataTableTasks collection allows scheduling (asynchronous) imports to Data Tables. Data is imported from external source, e.g. file stored on FTP server.
Currently, only one-time, immediately executed imports are supported.
Executing a GET request on ImportToDataTableTasks collection allows polling for scheduled import status (e.g. if it;s still in progress or already finished).
Request data format
Data part of request for scheduling a new import to Data Tables.
Data element children:
Element/attribute | Type | Notes |
---|---|---|
Source | complex | Imported file information. Required. |
Target | complex | Target task data. Required. |
ImportSetup | complex | Import settings, file settings, column mapping etc. Optional. If omitted, default settings will be used. |
Source element children:
Element/attribute | Type | Notes |
---|---|---|
Url | string | URL address of imported file. Supported protocols are HTTP, HTTPS, FTP, FTPS and SFTP. E.g. ftp://www.domain.com/myimportedfile.csv* |
Username | string | Username used for authentication. Optional. |
Password | string | Password used for authentication. Optional. |
FtpAuth | string | Authentication method for secure FTP servers. Optional. Valid values are: None — FTP server does not support secure authentication (default) ExplicitTls — Explicit TLS/SSL authentication ExplicitSsl — Explicit SSL only authentication ImplicitSsl — Implicit SSL authentication |
FtpUseActiveMode | boolean | If set to «true», active mode will be used for FTP connections. Default value is «false» — passive connection mode will be used. |
*Note: If you are importing a single CSV file, please make sure its name is the same as Data Table name you want to import data to.
Target element children:
Element/attribute | Type | Notes |
---|---|---|
Name | string | Import name. Used internally for easier identification. Required. |
ImportSetup element children:
Element/attribute | Type | Notes |
---|---|---|
Mode | string | Import mode. Import modes are exactly the same as adding modes. Optional. Defaults to «Add». |
Delimiter | string | CSV file delimiter. Optional. Default value is ‘,’ (comma). |
Quote | string | CSV file quoting character. Optional. Default value is ‘»‘ (double quote). |
Escape | string | CSV file escape character. Optional. Default value is ‘»‘ (double quote). |
Comment | string | CSV file comment character. Optional. Default value is zero-byte (undefined). |
Encoding | string | CSV file encoding. Optional. Default is «utf-8». List of recognized values. |
StartingLine | integer | Number of line in file that import will start from. Optional. Default is 0 (from the beginning). |
Supported import modes:
Mode | Behaviour |
---|---|
Add | If row does not exist in Data Table, it will be added. |
Replace | Non-existing rows will be added. Existing rows will be replaced. |
AddOrUpdate | Non-existing rows will be added. Existing rows will be updated. |
Response
Method returns ID of scheduled import. ID can be used to get import status using GET method.
Response Data element:
Element/attribute | Type | Notes |
---|---|---|
(Data element content) | int | ID of scheduled import. |
Examples
Scheduling a new Data Tables import with default options
Request:
POST https://api.esv2.com/v2/Api/ImportToDataTableTasks HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/xml
User-Agent: Jakarta Commons-HttpClient/3.1
Host: api.esv2.com
Content-Length: 353
<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<ApiKey>test_api_key1</ApiKey>
<Data>
<Source>
<Url>ftp://ftp.expertsender.com/Lists/table_name.csv</Url>
</Source>
<Target>
<Name>API test import</Name>
</Target>
</Data>
</ApiRequest>
Response:
HTTP/1.1 201 Created
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 25 Nov 2014 10:41:33 GMT
Content-Length: 147
<ApiResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Data>25</Data>
</ApiResponse>
Scheduling a new Data Tables import with full options
Request:
POST https://api.esv2.com/v2/Api/ImportToDataTableTasks HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/xml;charset=UTF-8
User-Agent: Jakarta Commons-HttpClient/3.1
Host: api.esv2.com
Content-Length: 810
<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<ApiKey>test_api_key1</ApiKey>
<Data>
<Source>
<Url>ftp://ftp.expertsender.com/Lists/table_name.csv</Url>
<Username>username</Username>
<Password>password</Password>
</Source>
<Target>
<Name>API test import </Name>
</Target>
<ImportSetup>
<Mode>Add</Mode>
<Delimiter>,</Delimiter>
<Quote>"</Quote>
<Escape>"</Escape>
<Comment>|</Comment>
<Encoding>UTF-8</Encoding>
<StartingLine>1</StartingLine>
</ImportSetup>
</Data>
</ApiRequest>