Working with Imports

Last updated: July 27th 2018

ExecuteFTPImport

Creates the import and executes it. This is an all-in-one call.

ExecuteFTPImport Endpoint
Method: POST
https://apinie.sensorpro.net/api/import/ExecuteFTPImport/[Token]

Copy to Clipboard

  • [Token] - replace with the access token returned by the login.
Header Values
Header Example Description
Content-Type application/json  

Simple Sample Request


    {
        "Tag":"List_A"
    }

Input Parameters

  • Token (string returned from login request)
  • ImportDefinition (object)
    • ImportData import information (array): array of contact records to add update.
      • Name: Import name must not be greater than 16 characters long. Should only contain characters a-z and 0 to 9.
      • Description: Import Description
      • QuoteChar: Quote character if specified in file. Default: "
      • ClearCrossXRef: Clear previous records imported
      • ExecuteImport: Execute import now if true.
    • FTP Configuration FTP site login details
      • FTPSite: FTP Site Address
      • FTPUser: FTP Username
      • FTPPwd: FTP Password
      • FTPSecure: Secure FTP (SFTP) – True or False (default is False)
      • FTPFileName: CSV file name
      • DeleteFileAfterImport: Remove file from ftp site when finished.
    • FieldMap (array) mapping between CSV file and email system. This maps the CSV file heading to internal field name in email system
      • FromField: Column heading in CSV file (based on the example CSV file at the start of this section email)
      • ToField: The field in the email system in this case personalemail (email maps to personalemail)

Response Output - This is what you should see...


{
    "ImportId":12,
    "Result":{
    "RequestId":"b780cad0-9ecf-4631-83f6-5b451c767d72",
    "ErrorMessages":[

    ],
    "StatusMesssages":[

    ],
        "TotalStatusMessages":0,
        "TotalErrors":0
    }
}
                                

Note: Executing an import is an asynchronous job. This means that once the API call is finished the import may be queued or still running. To check the status of the import you can use the GetImportStatus API call to test the status of the import.

Sample Code:
                                                
var client = new RestClient("https://apinie.sensorpro.net/api/import/ExecuteFTPImport/[Token]");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\\"ImportDefinition\":{\\"ImportName\":\"MyImport\",\\"Description\":\"My First import\",\\"MapDefinition\":\"\",\\"Status\":-1,\\"QuoteChar\":\"\\\"\",\\"ClearCrossXRef\":false,\\"FieldMap\":[\{\\"FromField\":\"email\",\\"ToField\":\"personalemail\",\\"ToMacro\":\"\"\}\],\\"FTPConfiguration\":{\\"FTPFileName\":\"ftpSampleFile.txt\",\\"FTPFileEncoding\":\"UTF8\",\\"FTPUser\":\"XXXX\",\\"FTPSite\":\"XXXX\",\\"FTPPwd\":\"XXXX\",\\"FTPSecure\":false,\\"DeleteFileAfterImport\":false\},\\"ExecuteImport\":true\},\\"Options\":{\"Parameters\":{},\"Action\":\"\"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
                                                
                                                
                                                
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
        CURLOPT_URL => "https://apinie.sensorpro.net/api/import/ExecuteFTPImport/[Token]",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => "{\\"ImportDefinition\":{\\"ImportName\":\"MyImport\",\\"Description\":\"My First import\",\\"MapDefinition\":\"\",\\"Status\":-1,\\"QuoteChar\":\"\\\"\",\\"ClearCrossXRef\":false,\\"FieldMap\":[\{\\"FromField\":\"email\",\\"ToField\":\"personalemail\",\\"ToMacro\":\"\"\}\],\\"FTPConfiguration\":{\\"FTPFileName\":\"ftpSampleFile.txt\",\\"FTPFileEncoding\":\"UTF8\",\\"FTPUser\":\"XXXX\",\\"FTPSite\":\"XXXX\",\\"FTPPwd\":\"XXXX\",\\"FTPSecure\":false,\\"DeleteFileAfterImport\":false\},\\"ExecuteImport\":true\},\\"Options\":{\"Parameters\":{},\"Action\":\"\"}}",
        CURLOPT_HTTPHEADER => array(
        "Content-Type: application/json"
    ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
                                                
                                                
                                                
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\\"ImportDefinition\":{\\"ImportName\":\"MyImport\",\\"Description\":\"My First import\",\\"MapDefinition\":\"\",\\"Status\":-1,\\"QuoteChar\":\"\\\"\",\\"ClearCrossXRef\":false,\\"FieldMap\":[\{\\"FromField\":\"email\",\\"ToField\":\"personalemail\",\\"ToMacro\":\"\"\}\],\\"FTPConfiguration\":{\\"FTPFileName\":\"ftpSampleFile.txt\",\\"FTPFileEncoding\":\"UTF8\",\\"FTPUser\":\"XXXX\",\\"FTPSite\":\"XXXX\",\\"FTPPwd\":\"XXXX\",\\"FTPSecure\":false,\\"DeleteFileAfterImport\":false\},\\"ExecuteImport\":true\},\\"Options\":{\"Parameters\":{},\"Action\":\"\"}}");
Request request = new Request.Builder()
.url("https://apinie.sensorpro.net/api/import/ExecuteFTPImport/[Token]")
.post(body)
.addHeader("Content-Type", "application/json")
.build();

Response response = client.newCall(request).execute();
                                                
                                                

GetImportStatus

Used to check if import has finished.

GetImportStatus Endpoint
Method: POST
https://apinie.sensorpro.net/api/import/GetImportStatus/[Token]

Copy to Clipboard

  • [Token] - replace with the access token returned by the login.
Header Values
Header Example Description
Content-Type application/json  

Simple Sample Request


    {
        "ImportId":10
    }

Input Parameters

  • ImportID - Import ID

Response Output - This is what you should see...


{
    "ImportId":12,
    "ActiveContacts":1,
    "Status":"Ready",
    "LastFileProcessedOn":"2016-01-20T09:57:27",
    "Result":{
    "RequestId":"b780cad0-9ecf-4631-83f6-5b451c767d72",
    "ErrorMessages":[

    ],
    "StatusMesssages":[

    ],
    "TotalStatusMessages":0,
    "TotalErrors":0
    }
}

                                
Sample Code:
                                                
var client = new RestClient("https://apinie.sensorpro.net/api/import/GetImportStatus/[Token]");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\\"ImportId\":9}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
                                                
                                                
                                                
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
        CURLOPT_URL => "https://apinie.sensorpro.net/api/import/GetImportStatus/[Token]",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => "{\\"ImportId\":9}",
        CURLOPT_HTTPHEADER => array(
        "Content-Type: application/json"
    ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
                                                
                                                
                                                
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\\"ImportId\":9}");
Request request = new Request.Builder()
.url("https://apinie.sensorpro.net/api/import/GetImportStatus/[Token]")
.post(body)
.addHeader("Content-Type", "application/json")
.build();

Response response = client.newCall(request).execute();
                                                
                                                

ClearTagList

Clear a single tag from all contacts (execute multiple times for multiple tags).

ClearTagList Endpoint
Method: DELETE
https://apinie.sensorpro.net/api/import/ClearTagList/[Token]

Copy to Clipboard

  • [Token] - replace with the access token returned by the login.
Header Values
Header Example Description
Content-Type application/json  

Simple Sample Request


"ListA"


Input Parameters

  • Tag The name of the tag to remove from all contacts

Response Output - This is what you should see...


{
    "Result":{
        "RequestId":"b780cad0-9ecf-4631-83f6-5b451c767d72",
        "ErrorMessages":[],
        "StatusMesssages":[],
            "TotalStatusMessages":0,
            "TotalErrors":0
    }
}
                                
Sample Code:
                                                
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "\"ListA\"");
Request request = new Request.Builder()
.url("https://apinie.sensorpro.net/api/import/ClearTagList/[Token]")
.delete(body)
.addHeader("Content-Type", "application/json")
.build();

Response response = client.newCall(request).execute();
                                                
                                                
                                                
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://apinie.sensorpro.net/api/import/ClearTagList/[Token]",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "DELETE",
    CURLOPT_POSTFIELDS => "\"ListA\"",
    CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json"
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
                                                
                                                
                                                
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "\"ListA\"");
Request request = new Request.Builder()
.url("https://apinie.sensorpro.net/api/import/ClearTagList/[Token]")
.delete(body)
.addHeader("Content-Type", "application/json")
.build();

Response response = client.newCall(request).execute();
                                                
                                                

Developers Love Us - Create Your Account Now!