Create an Import Definition

You can create an import definition to move information from your system or development environment to Marketing Cloud Engagement.

How to Create an Import Defintion 

This example demonstrates creating an ImportDefinition object. Use the example as an example to create your own API call. You must create the FileTransferActivity. Supply only the parameters to change when updating an ImportDefinition object.

Sample .NET Code 

1using System;
2using System.Configuration;
3using System.Data;
4using System.Linq;
5using System.Web;
6using System.Web.Security;
7using System.Web.UI;
8using System.Web.UI.HtmlControls;
9using System.Web.UI.WebControls;
10using System.Web.UI.WebControls.WebParts;
11using System.Xml.Linq;
12using etAPI;
13public partial class ImportDefinitionCreate : System.Web.UI.Page
14{
15    //Global Variables
16    private SoapClient client = new SoapClient();
17    protected void Page_Load(object sender, EventArgs e)
18    {
19        //Authenticate
20        client.ClientCredentials.UserName.UserName = System.Configuration.ConfigurationSettings.AppSettings["wsUserName"];
21        client.ClientCredentials.UserName.Password = System.Configuration.ConfigurationSettings.AppSettings["wsPassword"];
22        if (!IsPostBack)
23        {
24        }
25    }
26    protected void btnSubmit_Click(object sender, EventArgs e)
27    {
28        try
29        {
30            //Create a GUID to ensure a unique subscriber key
31            string strGUID = System.Guid.NewGuid().ToString();
32            //Create an Import Definition object
33            ImportDefinition id = new ImportDefinition();
34            id.Name = strGUID;
35            id.CustomerKey = strGUID;
36            //Optional
37            id.AllowErrors = true;
38            id.AllowErrorsSpecified = true;
39            //Associate Data-Extenison to Import-Defintion
40            DataExtension de = new DataExtension();
41            de.CustomerKey = "810f461c-231a-440a-8543-837460be6c7a";//required //The External Key of the Data Extension to import into
42            id.DestinationObject = de;
43            //Specify the notification type //optional
44            id.Notification = new AsyncResponse();
45            id.Notification.ResponseType = AsyncResponseType.email;
46            id.Notification.ResponseAddress = "help@example.com";
47            //Specify the File Transfer Location
48            id.RetrieveFileTransferLocation = new FileTransferLocation();
49            id.RetrieveFileTransferLocation.CustomerKey = "ExactTarget Enhanced FTP";//required
50            //Optional
51            id.UpdateType = ImportDefinitionUpdateType.Overwrite;
52            id.UpdateTypeSpecified = true;
53            //Map fields
54            id.FieldMappingType = ImportDefinitionFieldMappingType.InferFromColumnHeadings;//required
55            id.FieldMappingTypeSpecified = true;
56            //Specify the File naming Specifications
57            id.FileSpec = "TEST.csv";
58            //Specify the FileType
59            id.FileType = FileType.CSV;//required
60            id.FileTypeSpecified = true;
61            try
62            {
63                string cRequestID = String.Empty;
64                string cStatus = String.Empty;
65                //Call the Create method on the ImportDefinition object
66                CreateResult[] cResults = client.Create(new CreateOptions(), new APIObject[] { id }, out cRequestID, out cStatus);
67                //Display Results
68                lblMessage.Text += "Overall Create Status: " + cStatus;
69                lblMessage.Text += "<br/>";
70                lblMessage.Text += "Number of Results: " + cResults.Length;
71                lblMessage.Text += "<br/>";
72                //Loop through each object returned and display the StatusMessage
73                foreach (CreateResult cr in cResults)
74                {
75                    lblMessage.Text += "Status Message: " + cr.StatusMessage;
76                    lblMessage.Text += "<br/>";
77                }
78            }
79            catch (Exception exCreate)
80            {
81                //Set Message
82                lblMessage.Text += "<br/><br/>CREATE SEND ERROR:<br/>" + exCreate.Message;
83            }
84        }
85        catch (Exception exc)
86        {
87            //Set Message
88            lblMessage.Text += "<br/><br/>###ERROR<br/>" + exc.Message;
89        }
90    }
91}
1// Intialize the variables string requestID; string status;  // Create an Import Definition object ImportDefinition id = new ImportDefinition();
2id.Name = "Web Service Created Import Definition";
3id.CustomerKey = "1234";
4id.Description = "This import definition was created through the API.";
5// Allow errors during the import? (optional)
6id.AllowErrors = true;
7id.AllowErrorsSpecified = true; //.NET Specific
8// Specify the list (required)
9id.DestinationObject = new List();
10id.DestinationObject.ID = 566;
11id.DestinationObject.IDSpecified = true;
12// Specify the notification type (optional)
13id.Notification = new AsyncResponse();
14id.Notification.ResponseType = AsyncResponseType.email;
15id.Notification.ResponseAddress = "dsmith@example.com";
16// Specify the File Transfer Location (where is the file coming from?) (required)
17id.RetrieveFileTransferLocation = new FileTransferLocation();
18id.RetrieveFileTransferLocation.CustomerKey = "ExactTarget Enhanced FTP";
19// Specify the UpdateType (optional)
20id.UpdateType = ImportDefinitionUpdateType.AddAndDoNotUpdate;
21id.UpdateTypeSpecified = true;
22// Map fields (required)
23id.FieldMappingType = ImportDefinitionFieldMappingType.MapByOrdinal;
24id.FieldMappingTypeSpecified = true;
25id.FieldMaps = new FieldMap[2];
26id.FieldMaps[0] = new FieldMap();
27id.FieldMaps[0].DestinationName = "Subscriber Key";
28id.FieldMaps[0].Item = "1";
29id.FieldMaps[1] = new FieldMap();
30id.FieldMaps[1].DestinationName = "Email Address";
31id.FieldMaps[1].Item = "2";
32// Specify the File naming Specifications
33id.FileSpec = "APIImport%%Year%%%%Month%%%%Day%%.txt";
34// Specify the FileType
35id.FileType = FileType.CSV;
36id.FileTypeSpecified = true;
37// Create the Import Definition
38CreateResult[] results = integrationFramework.Create(new CreateOptions(), new APIObject[] { id }, out requestID, out status);
39// Print out overall results
40System.Text.StringBuilder sb = new System.Text.StringBuilder();
41sb.Append("Add Import Definition");
42sb.AppendFormat("\nOverall result: {0}.  RequestID: {1}", status, requestID);
43// Print out results for each new object created
44for (int cntr = 0; cntr < results.Length; cntr++)
45{
46       sb.AppendFormat("\nResults for object {0}: Status code: {1}.  Message: {2}.  ExactTargetObjectID: {3} Error Code {4}", cntr, results[cntr].StatusCode, results[cntr].StatusMessage, results[cntr].NewObjectID, results[cntr].ErrorCode);
47}
48Console.WriteLine(sb.ToString());

Output 

1Add Import Definition Overall result: OK.  RequestID: fd515c55-b7f6-43e3-9bb6-d7c736e33b8c Results for object 0: Status code: OK.  Message: ImportDefinition created. ExactTargetObjectID: 537496f3-cbe0-dc11-bfbd-0017a43c44a8 Error Code 0

Sample .NET Code - Create an Import Definition using Manual Mapping 

1private void CreateImportDef()
2                {
3                    SoapClient framework = new SoapClient();
4                    framework.ClientCredentials.UserName.UserName = "XXXXX";
5                    framework.ClientCredentials.UserName.Password = "XXXXX";
6                    string requestID;
7                    string status;
8                    ImportDefinition id = new ImportDefinition();
9                    id.Name = "Web Service Created Import Definition With ManualMap";
10                    id.CustomerKey = "12345";
11                    id.Description = "";
12
13                    id.AllowErrors = true;
14                    id.AllowErrorsSpecified = true;
15
16                    id.DestinationObject = new DataExtension();
17                    id.DestinationObject.ObjectID = "12345";
18                    id.Notification = new AsyncResponse();
19                    id.Notification.ResponseType = AsyncResponseType.email;
20                    id.Notification.ResponseAddress = "aruiz@example.com";
21            id.RetrieveFileTransferLocation = new FileTransferLocation();
22            id.RetrieveFileTransferLocation.CustomerKey = "ExactTarget Enhanced FTP";
23            id.UpdateType = ImportDefinitionUpdateType.Overwrite;
24            id.UpdateTypeSpecified = true;
25            //Specify details about the field mapping
26            id.FieldMappingType = ImportDefinitionFieldMappingType.ManualMap;
27            id.FieldMappingTypeSpecified = true;
28            FieldMap fmEmail = new FieldMap();
29            fmEmail.Item = "Test1";
30            fmEmail.DestinationName = "EMAIL";
31            FieldMap fmReason = new FieldMap();
32            fmReason.Item = "Test2";
33            fmReason.DestinationName = "Reason";
34            id.FieldMaps = new FieldMap[] { fmEmail, fmReason };
35
36            //Specify details about the file
37            id.FileSpec = "MacTest.txt";
38            id.FileType = FileType.CSV;
39            id.FileTypeSpecified = true;
40            // Create the Import Definition
41            CreateResult[] results = framework.Create(new CreateOptions(), new APIObject[] { id }, out requestID, out status);
42            Console.WriteLine("\nOverall result: {0}. RequestID: {1}", status, requestID);
43            for (int cntr = 0; cntr < results.Length; cntr++)
44            {
45                Console.WriteLine("\nResults for object {0}: Status code: {1}. Message: {2}. ExactTargetObjectID: {3} Error Code {4}", cntr, results[cntr].StatusCode, results[cntr].StatusMessage, results[cntr].NewObjectID, results[cntr].ErrorCode);
46            }
47        }

Create and Perform an Import Definition 

1public static PerformResult[] importSubscribers(SoapClient client, int MID, String ListName, String DefnName, String DataFile, String emailAddress, String TransferLocation)
2{
3    String pStatus = String.Empty;
4    String pStatusMsg = String.Empty;
5    String requestID = String.Empty;
6    CreateResult[] result = Utilities.CreateImportDefinition(client, MID, ListName, DefnName, DataFile, emailAddress, TransferLocation);
7    if (result != null)
8    {
9        APIObject[] Definitions = new APIObject[1];
10        Definitions[0] = result[0].Object;
11        PerformOptions pOpts = new PerformOptions();
12        pOpts.Client = Utilities.getClientID(MID);
13        PerformResult[] pResult = client.Perform(pOpts, "Start", Definitions, out pStatus, out pStatusMsg, out requestID);
14        return pResult;
15    }
16    else
17    {
18        return null;
19    }
20}
21public static CreateResult[] CreateImportDefinition(SoapClient client, int MID, String ListName, String ImportDefnName, String DataFile, String emailAddress, String TransferLocation)
22{
23    string strGUID = System.Guid.NewGuid().ToString();
24
25    // Create the Definition object.
26    ImportDefinition importDefn = new ImportDefinition();
27    // Set the import definition Name and External Key.
28    importDefn.Name = ImportDefnName;
29    importDefn.CustomerKey = strGUID;
30    // Specify the account where it is created.
31    importDefn.Client = getClientID(MID);
32    // Set it up so import doesn't fail because of an error.
33    importDefn.AllowErrors = true;
34    importDefn.AllowErrorsSpecified = true;
35    // Set it up to send notification when the import is complete.
36    importDefn.Notification = new AsyncResponse();
37    importDefn.Notification.ResponseType = AsyncResponseType.email;
38    importDefn.Notification.ResponseAddress = emailAddress;
39    // Identify the location of the data file.
40    importDefn.RetrieveFileTransferLocation = new FileTransferLocation();
41    importDefn.RetrieveFileTransferLocation.CustomerKey = TransferLocation;
42    // Specify the way the subscriber list is updated.
43    importDefn.UpdateType = ImportDefinitionUpdateType.AddAndUpdate;
44    importDefn.UpdateTypeSpecified = true;
45    // Specify that the import file has column heading on the first row.
46    importDefn.FieldMappingType = ImportDefinitionFieldMappingType.InferFromColumnHeadings;
47    importDefn.FieldMappingTypeSpecified = true;
48    // Identify the data file name and file type.
49    importDefn.FileSpec = DataFile;
50    importDefn.FileType = FileType.CSV;
51    importDefn.FileTypeSpecified = true;
52    // Get the list ID of the list to which the data is imported, using the list name.
53    int listID = Utilities.getListID(client, MID, ListName);
54    // Specify the list on the import definition.
55    List list = new List();
56    list.ID = listID;
57    list.IDSpecified = true;
58    importDefn.DestinationObject = list;
59    // Create the import definition and return it for use.
60    CreateResult[] results = null;
61    String requestID = String.Empty;
62    String status = String.Empty;
63    try
64    {
65        results = client.Create(new CreateOptions(), new APIObject[] { importDefn }, out requestID, out status);
66    }
67    catch (Exception e)
68    {
69        Console.WriteLine(e.Message);
70    }
71    if (status == "OK")
72    {
73        return results;
74    }
75    else
76    {
77        return null;
78    }
79}
80public static ClientID getClientID(int MID)
81{
82    ClientID clientID = new ClientID();
83    clientID.ID = MID;
84    clientID.IDSpecified = true;
85    return clientID;
86}
87public static SoapClient getClient()
88{
89    SoapClient client = new SoapClient();
90    client.ClientCredentials.UserName.UserName = "userID";
91    client.ClientCredentials.UserName.Password = "userIDPassword";
92    return client;
93}
94
95public static int getListID(SoapClient client, int MID, String listName)
96{
97    int listID = 0;
98    APIObject[] results;
99    String requestID;
100    String status;
101    RetrieveRequest rr = new RetrieveRequest();
102    rr.ObjectType = "List";
103    rr.ClientIDs = new ClientID[1];
104    rr.ClientIDs[0] = new ClientID();
105    rr.ClientIDs[0].ID = MID;
106    rr.ClientIDs[0].IDSpecified = true;
107    SimpleFilterPart sf1 = new SimpleFilterPart();
108    sf1.Property = "ListName";
109    sf1.SimpleOperator = SimpleOperators.equals;
110    sf1.Value = new String[] { listName };
111    rr.Filter = sf1;
112    rr.Properties = new string[] { "ID" };
113    status = client.Retrieve(rr, out requestID, out results);
114    if (results.Length > 0)
115    {
116        listID = results[0].ID;
117    }
118    return listID;
119}

Use the DataFormattingLocale property to specify how dates are formatted in import data. Marketing Cloud Engagement uses this information to ensure the data is interpreted correctly when it is being loaded. For example, you can use DateFormattingLocale to determine whether ‘01-09-2010’ means January 9th, 2010 or September 1st, 2010. If no LocaleCode is supplied, the call defaults to “en-US”.

This sample code shows how to set the value for DateFormattingLocale for Create and Update methods:

1ExactTarget.Integration.WSDL.ImportDefinition importDef = new ImportDefinition();
2importDef.DateFormattingLocale = new Locale();
3importDef.DateFormattingLocale.LocaleCode = "en-US"; // For US DateFormat

Sample Java Code (Axis 1.4) 

1public class ImportDefTestCase extends BaseTestCase {
2    public void testCreateImportDef() throws RemoteException {
3        Soap stub = init();
4        ImportDefinition impDef = new ImportDefinition();
5        impDef.setName("ImportDefinitionSeed_1");
6        impDef.setCustomerKey("ImportDefinitionSeed_1");
7        impDef.setDescription("This import definition was created through the API.");
8        impDef.setAllowErrors(true);
9        impDef.setDestinationObject(new List());
10        impDef.getDestinationObject().setID(new Integer(2464));
11        // Specify the notification type (optional)
12        AsyncResponse asyncResponse = new AsyncResponse();
13        asyncResponse.setResponseType(AsyncResponseType.email);
14        asyncResponse.setResponseAddress("test@example.com");
15        impDef.setNotification(asyncResponse);
16        FileTransferLocation fileTransferLocation = new FileTransferLocation();
17        fileTransferLocation.setCustomerKey("ExactTarget Enhanced FTP");
18        impDef.setRetrieveFileTransferLocation(fileTransferLocation);
19        impDef.setUpdateType(ImportDefinitionUpdateType.AddAndDoNotUpdate);
20        // Map fields (required)
21        impDef.setFieldMappingType(ImportDefinitionFieldMappingType.MapByOrdinal);
22        FieldMap map1 = new FieldMap();
23        map1.setDestinationName("Subscriber Key");
24        map1.setSourceName("1");
25        //map1.setSourceOrdinal(new Integer(1));
26        FieldMap map2 = new FieldMap();
27        map2.setDestinationName("Email Address");
28        //map2.setSourceOrdinal(new Integer(2));
29        map2.setSourceName("2");
30        FieldMap[] maps = {map1, map2};
31        impDef.setFieldMaps(maps);
32        impDef.setFileSpec("12345.csv");
33        // Specify the FileType
34        impDef.setFileType(FileType.CSV);
35        //Assign ImportDefinition to sub-account
36        ClientID clientID = new ClientID();
37        clientID.setPartnerClientKey("12345");// Partner Key
38        impDef.setClient(clientID);
39        CreateRequest createRequest = new CreateRequest();
40        createRequest.setOptions(new CreateOptions());
41        APIObject[] apiObjectList = {impDef};
42        createRequest.setObjects(apiObjectList);
43        CreateResponse createResponse = stub.create(createRequest);
44        System.out.println("CreateResponse ::: " + createResponse.getOverallStatus());
45    }
46    public void testCreateImportDefToDataExtension() throws RemoteException {
47        try {
48            Soap stub = init();
49            DataExtension dataExtension = getDataExtension(stub);
50            ImportDefinition impDef = new ImportDefinition();
51            impDef.setName("Import_Definition_UpdateButDoNotAdd");
52            impDef.setCustomerKey("Import_UpdateButDoNotAdd_Key");
53            impDef.setDescription("Import_Definition_UpdateButDoNotAdd_Desc");
54            impDef.setAllowErrors(true);
55            //dataExtension.setID(new Integer(12345));
56            impDef.setDestinationObject(dataExtension);
57            // Specify the notification type (optional)
58            AsyncResponse asyncResponse = new AsyncResponse();
59            asyncResponse.setResponseType(AsyncResponseType.email);
60            asyncResponse.setResponseAddress("test@example.com");
61            impDef.setNotification(asyncResponse);
62            FileTransferLocation fileTransferLocation = new FileTransferLocation();
63            fileTransferLocation.setCustomerKey("ExactTarget Enhanced FTP");
64            impDef.setRetrieveFileTransferLocation(fileTransferLocation);
65            impDef.setUpdateType(ImportDefinitionUpdateType.UpdateButDoNotAdd);
66            // Map fields (required)
67            //impDef.setFieldMappingType(ImportDefinitionFieldMappingType.MapByOrdinal);
68            impDef.setFieldMappingType(ImportDefinitionFieldMappingType.InferFromColumnHeadings);
69            //impDef.setSubscriberImportType(ImportDefinitionSubscriberImportType.Email);
70            FieldMap map1 = new FieldMap();
71            map1.setDestinationName("EmailId");
72            map1.setSourceOrdinal(new Integer(1));
73            FieldMap map2 = new FieldMap();
74            map2.setDestinationName("StatusField");
75            map2.setSourceOrdinal(new Integer(2));
76            FieldMap[] maps = {map1, map2};
77            impDef.setFieldMaps(maps);
78            impDef.setFileSpec("Test2.csv");
79            // Specify the FileType
80            impDef.setFileType(FileType.CSV);
81            //impDef.setClient(dataExtension.getClient());
82            CreateRequest createRequest = new CreateRequest();
83            createRequest.setOptions(new CreateOptions());
84            APIObject[] apiObjectList = {impDef};
85            createRequest.setObjects(apiObjectList);
86            CreateResponse createResponse = stub.create(createRequest);
87            System.out.println("CreateResponse ::: " + createResponse.getOverallStatus());
88        } catch (RemoteException e) {
89            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
90        } catch (IOException e) {
91            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
92        }
93    }

This sample code creates an import definition and associates it with a specific data extension.

1/**
2     * Creating Import-Definition and associating it with a Data Extension
3     *
4     * @throws RemoteException
5     */
6   public void testCreateImportDefToDataExtensionMarket2Lead() throws RemoteException{
7        try {
8            Soap_PortType stub = init();
9            ImportDefinition impDef = new ImportDefinition();
10            impDef.setName("Import_To_DE");
11            impDef.setCustomerKey("Import_To_DE_Key");
12            impDef.setDescription("Import_To_DE");
13            impDef.setAllowErrors(true);
14            // Associate Data-Extenison to Import-Defintion
15        DataExtension dataExtension = new DataExtension();
16            dataExtension.setCustomerKey("UsingAPI_For_Key");
17            impDef.setDestinationObject(dataExtension);
18            // Specify the notification
19            AsyncResponse asyncResponse = new AsyncResponse();
20            asyncResponse.setResponseType(AsyncResponseType.email);
21            asyncResponse.setResponseAddress("response@example.com");
22            impDef.setNotification(asyncResponse);
23        //Specify Location of File, In this case it is FTP
24        FileTransferLocation fileTransferLocation = new FileTransferLocation();
25            fileTransferLocation.setCustomerKey("ExactTarget Enhanced FTP");
26            impDef.setRetrieveFileTransferLocation(fileTransferLocation);
27            impDef.setUpdateType(ImportDefinitionUpdateType.AddAndDoNotUpdate);
28            //Map fields by Column headings.
29            impDef.setFieldMappingType(ImportDefinitionFieldMappingType.InferFromColumnHeadings);
30            FieldMap map1 = new FieldMap();
31            map1.setDestinationName("EmailAddress");
32            //map1.setSourceOrdinal(new Integer(1));
33            FieldMap map2 = new FieldMap();
34            map2.setDestinationName("ChannelUser");
35            //map2.setSourceOrdinal(new Integer(2));
36            FieldMap map3 = new FieldMap();
37            map3.setDestinationName("ChannelUser_EmailAddress");
38            FieldMap map4 = new FieldMap();
39            map4.setDestinationName("Demographic_Address");
40            FieldMap[] maps = {map1, map2, map3, map4};
41            impDef.setFieldMaps(maps);
42            impDef.setFileSpec("Import2L.csv");
43            // Specify the FileType
44            impDef.setFileType(FileType.CSV);
45            CreateRequest createRequest = new CreateRequest();
46            createRequest.setOptions(new CreateOptions());
47            APIObject[] apiObjectList = {impDef};
48            createRequest.setObjects(apiObjectList);
49            CreateResponse createResponse = stub.create(createRequest);
50            //ImportResultsSummary importResultsSummary = (ImportResultsSummary) createResponse.getResults();
51            System.out.println("CreateResponse ::: " + createResponse.getOverallStatus());
52
53            }
54            catch (RemoteException e)
55            {
56            e.printStackTrace();
57            }
58            catch (IOException e)
59            {
60            e.printStackTrace();
61            }
62        }

Sample Ruby Code 

1require 'rubygems'
2gem 'soap4r'
3require 'soap/wsdlDriver'
4require 'soap/header/simplehandler'
5require 'defaultDriver.rb'
6require 'authStub.rb'
7#Async create options
8#options = CreateOptions.new(nil,nil,nil,nil,nil,nil,nil,nil,'Asynchronous')
9options = nil
10customerKey = 'API-Test-1'
11desc = customerKey + ' created through the API'
12de = DataExtension.new(nil,nil,nil,nil,nil,nil,nil,'APITestDe0',nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil)
13importDef = ImportDefinition.new(nil,nil,nil,nil,nil,nil,nil,customerKey,nil,nil,customerKey,desc,nil,nil,0,de,'InferFromColumnHeadings',nil,'Members_New.txt','TAB',AsyncResponse.new('email','acruz@example.com','Always',1,0,0),FileTransferLocation.new(nil,nil,nil,nil,nil,nil,nil,'ExactTarget Enhanced FTP',nil,nil),nil,'AddAndUpdate',nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,1,nil)
14apiObj = importDef
15resp = $driver.create(CreateRequest.new(options,[*apiObj]))

SOAP Request For Import Definiton Creation 

The envelope below infers mapping from column headings:

1<?xml version="1.0" encoding="UTF-8"?>
2<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3    <soapenv:Header>
4        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">             <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-10154161">
5                <wsse:Username>XXXX</wsse:Username>
6                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XXXX</wsse:Password>
7            </wsse:UsernameToken>
8        </wsse:Security>
9    </soapenv:Header>
10    <soapenv:Body>
11        <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
12            <Options></Options>
13            <Objects xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI" xsi:type="ns1:ImportDefinition">
14                <CustomerKey>Import_To_DE_Market2Lead_Key</CustomerKey>
15                <Name>Import_To_DE_Market2Lead</Name>
16                <Description>Import_To_DE_Market2Lead</Description>
17                <AllowErrors>true</AllowErrors>
18                <DestinationObject xsi:type="ns1:DataExtension">
19                    <CustomerKey>UsingAPI_For_Market2Lead_Key</CustomerKey>
20                    <ObjectID xsi:nil="true"/>
21                </DestinationObject>
22                <FieldMappingType>InferFromColumnHeadings</FieldMappingType>
23                <FileSpec>Import2M2L.csv</FileSpec>
24                <FileType>CSV</FileType>
25                <Notification>
26                    <ResponseType>email</ResponseType>
27                    <ResponseAddress>response@example.com</ResponseAddress>
28                </Notification>
29                <RetrieveFileTransferLocation>
30                    <CustomerKey>ExactTarget Enhanced FTP</CustomerKey>
31                </RetrieveFileTransferLocation>
32                <UpdateType>AddAndDoNotUpdate</UpdateType>
33            </Objects>
34        </CreateRequest>
35    </soapenv:Body>
36</soapenv:Envelope>

The envelope below maps fields via ordinals:

1<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
2   <soap:Header>
3      <wsa:Action>Create</wsa:Action>
4      <wsa:MessageID>urn:uuid:e133baeb-0ea6-48c4-97a2-a35259159789</wsa:MessageID>
5      <wsa:ReplyTo>
6         <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
7      </wsa:ReplyTo>
8      <wsa:To>https://YOUR_SUBDOMAIN.soap.marketingcloudapis.com/Service.asmx</wsa:To>
9      <wsse:Security soap:mustUnderstand="1">
10         <wsse:UsernameToken wsu:Id="SecurityToken-cfa5c193-106c-42b5-80fc-2f1bd831e480">
11            <wsse:Username>ccc</wsse:Username>
12            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">ccc</wsse:Password>
13         </wsse:UsernameToken>
14      </wsse:Security>
15   </soap:Header>
16   <soap:Body>
17      <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
18         <Options/>
19         <Objects xsi:type="ImportDefinition">
20            <ObjectID xsi:nil="true"/>
21            <CustomerKey>UsingAPI</CustomerKey>
22            <Name>UsingAPI</Name>
23            <Description>UsingAPI to Import to DE Definition</Description>
24            <DestinationObject xsi:type="DataExtension">
25               <Client>
26                  <ID>113903</ID>
27               </Client>
28               <CreatedDate>2008-10-16T14:53:26.613</CreatedDate>
29               <ObjectID>2300bb16-bc9b-dd11-be9d-001e0bcf2c98</ObjectID>
30               <CustomerKey>Test2_Key</CustomerKey>
31               <Name>Test2</Name>
32              <Description/>
33               <IsSendable>true</IsSendable>
34               <IsTestable>false</IsTestable>
35               <SendableSubscriberField>
36                  <Name>_SubscriberKey</Name>
37               </SendableSubscriberField>
38            </DestinationObject>
39            <FieldMappingType>MapByOrdinal</FieldMappingType>
40            <FieldMaps>
41               <FieldMap>
42                  <SourceName>1</SourceName>
43                  <DestinationName>EmailId</DestinationName>
44               </FieldMap>
45               <FieldMap>
46                  <SourceName>2</SourceName>
47                  <DestinationName>StatusField</DestinationName>
48               </FieldMap>
49            </FieldMaps>
50            <FileSpec>Test2.csv</FileSpec>
51            <FileType>CSV</FileType>
52            <Notification>
53               <ResponseType>email</ResponseType>
54               <ResponseAddress>bgogineni@exacttarget.com</ResponseAddress>
55            </Notification>
56            <RetrieveFileTransferLocation>
57               <ObjectID xsi:nil="true"/>
58               <CustomerKey>ExactTarget Enhanced FTP</CustomerKey>
59            </RetrieveFileTransferLocation>
60            <UpdateType>AddAndDoNotUpdate</UpdateType>
61         </Objects>
62      </CreateRequest>
63   </soap:Body>
64</soap:Envelope>

SOAP Response For Import Definiton Creation 

The API returns a response like this for inferred field mappings:

1<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
2    <soap:Header>
3        <wsa:Action>CreateResponse</wsa:Action>
4        <wsa:MessageID>urn:uuid:107dc09d-fdff-408e-af80-373012788c53</wsa:MessageID>
5        <wsa:RelatesTo>urn:uuid:02be8551-f51a-45c2-a298-2cfbd23fe715</wsa:RelatesTo>
6        <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
7        <wsse:Security>
8        </wsse:Security>
9    </soap:Header>
10    <soap:Body>
11        <CreateResponse xmlns="http://exacttarget.com/wsdl/partnerAPI">
12            <Results>
13                <StatusCode>OK</StatusCode>
14                <StatusMessage>ImportDefinition created.</StatusMessage>
15                <OrdinalID>0</OrdinalID>
16                <NewID>0</NewID>
17                <NewObjectID>4da7bd99-6d0e-de11-b30f-001cc494ae9e</NewObjectID>
18                <Object xsi:type="ImportDefinition">
19                    <ObjectID>4da7bd99-6d0e-de11-b30f-001cc494ae9e</ObjectID>
20                    <CustomerKey>Import_To_DE_Market2Lead_Key</CustomerKey>
21                    <Name>Import_To_DE_Market2Lead</Name>
22                    <Description>Import_To_DE_Market2Lead</Description>
23                    <AllowErrors>true</AllowErrors>
24                    <DestinationObject xsi:type="DataExtension">
25                        <ObjectID xsi:nil="true"/>
26                        <CustomerKey>UsingAPI_For_Market2Lead_Key</CustomerKey>
27                    </DestinationObject>
28                    <FieldMappingType>InferFromColumnHeadings</FieldMappingType>
29                    <FileSpec>Import2M2L.csv</FileSpec>
30                    <FileType>CSV</FileType>
31                    <Notification>
32                        <ResponseType>email</ResponseType>
33                            <ResponseAddress>response@exacttarget.com</ResponseAddress>
34                        </Notification>
35                    <RetrieveFileTransferLocation>
36                        <ObjectID xsi:nil="true"/>
37                        <CustomerKey>ExactTarget Enhanced FTP</CustomerKey>
38                    </RetrieveFileTransferLocation>
39                    <UpdateType>AddAndDoNotUpdate</UpdateType>
40                </Object>0
41            </Results>
42            <RequestID>a491e5d7-6388-4e19-afb8-506d4136542a</RequestID>
43            <OverallStatus>OK</OverallStatus>
44        </CreateResponse>
45    </soap:Body>
46</soap:Envelope>

How to Start the Import Definition 

After starting the import definition, the system returns “TaskResultID,” capture the “TaskResultID” and check against the system to verify if import is completed or not.

1/**
2     * Shows how to start Import-Definitions
3     * Capture TaskResultID from response object and use it for checking import start
4     * status.
5     * @throws RemoteException
6     */
7     public void testStartImportDefinition() throws RemoteException {
8        try             {
9            Soap_PortType stub = init();
10            // Create the ImportDefinition
11            ImportDefinition impDef = new ImportDefinition();
12            impDef.setCustomerKey("Import_To_DE_Market2Lead_Key");
13            PerformRequestMsg performRequestMsg = new PerformRequestMsg();
14            performRequestMsg.setAction("start");
15            performRequestMsg.setOptions(new PerformOptions());
16            performRequestMsg.setDefinitions(new InteractionBaseObject[]{impDef});
17            PerformResponseMsg performResponseMsg = stub.perform(performRequestMsg);
18            System.out.println(performResponseMsg.getOverallStatusMessage());
19            }             catch (RemoteException e)             {
20            e.printStackTrace();
21            } catch (IOException e)             {
22            e.printStackTrace();
23            }
24         }

SOAP Request For Starting Import Definiton 

1<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2    <soapenv:Header>
3        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
4            <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-25926258">
5                <wsse:Username>XXXX</wsse:Username>
6                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XXXX</wsse:Password>
7            </wsse:UsernameToken>
8        </wsse:Security>
9    </soapenv:Header>
10    <soapenv:Body>
11        <PerformRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
12            <Options></Options>
13            <Action>start</Action>
14            <Definitions>
15                <Definition xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI" xsi:type="ns1:ImportDefinition">
16                    <CustomerKey>Import_To_DE_Market2Lead_Key</CustomerKey>
17                </Definition>
18            </Definitions>
19        </PerformRequestMsg>
20    </soapenv:Body>
21</soapenv:Envelope>

SOAP Response For Starting Import Definiton 

1<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
2    <soap:Header>
3        <wsa:Action>PerformResponse</wsa:Action>
4        <wsa:MessageID>urn:uuid:9d81e7a4-74b5-441f-9ded-7fb2f526bf0e</wsa:MessageID>
5        <wsa:RelatesTo>urn:uuid:d1c32df8-bae7-47dd-889e-4de8fbb05ff7</wsa:RelatesTo>
6        <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
7        <wsse:Security>
8        </wsse:Security>
9    </soap:Header>
10    <soap:Body>
11        <PerformResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
12            <Results>
13                <Result>
14                    <StatusCode>OK</StatusCode>
15                    <StatusMessage>ImportDefinition performed AsyncID:130040236</StatusMessage>
16                    <Object xsi:type="ImportDefinition">
17                        <ObjectID xsi:nil="true"/>
18                        <CustomerKey>Import_To_DE_Market2Lead_Key</CustomerKey>
19                    </Object>
20                    <Task>
21                        <StatusCode>OK</StatusCode>
22                        <StatusMessage>OK</StatusMessage>
23                        <ID>130040236</ID>
24                        <InteractionObjectID>f2471f20-6f0e-de11-b30f-001cc494ae9e</InteractionObjectID>
25                    </Task>
26                </Result>
27            </Results>
28            <OverallStatus>OK</OverallStatus>
29            <OverallStatusMessage/>
30            <RequestID>360ecbe7-70aa-4591-8bca-3d220445b531</RequestID>
31       </PerformResponseMsg>
32    </soap:Body>
33</soap:Envelope>

How to Retrieve the Import Start Results Summary 

1/**
2     * Shows how to retrieve import start results summary
3     *
4     * @throws RemoteException
5     */
6    public void testRetrieveImportDefinitionSummary() throws RemoteException {
7        try
8            {
9            Soap_PortType stub = init();
10            RetrieveRequest request = new RetrieveRequest();
11            request.setObjectType("ImportResultsSummary");
12            ImportDefinition impDef = new ImportDefinition();
13            impDef.setCustomerKey("Import_To_DE_Market2Lead_Key");
14            String[] string = {"ImportDefinitionCustomerKey", "ImportType", "ImportStatus", "ID", "ObjectID", "NumberDuplicated", "NumberErrors", "NumberSuccessful", "DestinationID", "TaskResultID"};
15            request.setProperties(string);
16            RetrieveRequestMsg requestMsg = new RetrieveRequestMsg();
17            SimpleFilterPart filterPart = new SimpleFilterPart();
18            filterPart.setProperty("TaskResultID");
19            String[] values = {"130040236"};
20            filterPart.setValue(values);
21            filterPart.setSimpleOperator(SimpleOperators.equals);
22            request.setFilter(filterPart);
23            requestMsg.setRetrieveRequest(request);
24            RetrieveResponseMsg responseMsg = stub.retrieve(requestMsg);
25            System.out.println(responseMsg.getOverallStatus());
26            }
27            catch (RemoteException e)
28            {
29            e.printStackTrace();
30            }
31            catch (IOException e)
32            {
33            e.printStackTrace();
34            }
35      }

SOAP Request to Get Start Summary 

1<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2    <soapenv:Header>
3        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
4            <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-12793227">
5                <wsse:Username>XXXX</wsse:Username>
6                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XXXX</wsse:Password>
7            </wsse:UsernameToken>
8        </wsse:Security>
9    </soapenv:Header>
10    <soapenv:Body>
11        <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
12            <RetrieveRequest>
13                <ObjectType>ImportResultsSummary</ObjectType>
14                <Properties>ImportDefinitionCustomerKey</Properties>
15                <Properties>ImportType</Properties>
16                <Properties>ImportStatus</Properties>
17                <Properties>ID</Properties>
18                <Properties>ObjectID</Properties>
19                <Properties>NumberDuplicated</Properties>
20                <Properties>NumberErrors</Properties>
21                <Properties>NumberSuccessful</Properties>
22                <Properties>DestinationID</Properties>
23                <Properties>TaskResultID</Properties>
24                <Filter xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI" xsi:type="ns1:SimpleFilterPart">
25                    <Property>TaskResultID</Property>
26                    <SimpleOperator>equals</SimpleOperator>
27                    <Value>130040236</Value>
28                </Filter>
29            </RetrieveRequest>
30        </RetrieveRequestMsg>
31    </soapenv:Body>
32</soapenv:Envelope>

SOAP Response to Get Start Summary 

1<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
2    <soap:Header>
3        <wsa:Action>RetrieveResponse</wsa:Action>
4        <wsa:MessageID>urn:uuid:09b16372-7a90-47d2-a1dd-669d7c00bcf9</wsa:MessageID>
5        <wsa:RelatesTo>urn:uuid:6d510939-fee8-4b7d-8630-49cfc27b207d</wsa:RelatesTo>
6        <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
7        <wsse:Security>
8        </wsse:Security>
9    </soap:Header>
10    <soap:Body>
11        <RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
12            <OverallStatus>OK</OverallStatus>
13            <RequestID>f37fa7f0-0203-4f45-9cde-4eec947d13bd</RequestID>
14            <Results xsi:type="ImportResultsSummary">
15                <ObjectID>f7471f20-6f0e-de11-b30f-001cc494ae9e</ObjectID>
16                <ImportDefinitionCustomerKey>Import_To_DE_Market2Lead_Key</ImportDefinitionCustomerKey>
17                <DestinationID>UsingAPI_For_Market2Lead_Key</DestinationID>
18                <NumberSuccessful>2</NumberSuccessful>
19                <NumberDuplicated>0</NumberDuplicated>
20                <NumberErrors>0</NumberErrors>
21                <ImportType>Data Extensions</ImportType>
22                <ImportStatus>Completed</ImportStatus>
23                <TaskResultID>130040236</TaskResultID>
24            </Results>
25        </RetrieveResponseMsg>
26    </soap:Body>
27</soap:Envelope>

SOAP Envelope to Create Import Definition with MapByOrdinal 

1<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
2   <soap:Header>
3      <wsa:Action>Create</wsa:Action>
4      <wsa:MessageID>urn:uuid:e133baeb-0ea6-48c4-97a2-a35259159789</wsa:MessageID>
5      <wsa:ReplyTo>
6         <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
7      </wsa:ReplyTo>
8      <wsa:To>https://YOUR_SUBDOMAIN.soap.marketingcloudapis.com/Service.asmx</wsa:To>
9      <wsse:Security soap:mustUnderstand="1">
10         <wsse:UsernameToken wsu:Id="SecurityToken-cfa5c193-106c-42b5-80fc-2f1bd831e480">
11            <wsse:Username>xxxx</wsse:Username>
12            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxxx</wsse:Password>
13         </wsse:UsernameToken>
14      </wsse:Security>
15   </soap:Header>
16   <soap:Body>
17      <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
18         <Options/>
19         <Objects xsi:type="ImportDefinition">
20            <ObjectID xsi:nil="true"/>
21            <CustomerKey>UsingAPI</CustomerKey>
22            <Name>UsingAPI</Name>
23            <Description>UsingAPI to Import to DE Definition</Description>
24            <DestinationObject xsi:type="DataExtension">
25               <Client>
26                  <ID>123</ID>
27               </Client>
28               <CreatedDate>2008-10-16T14:53:26.613</CreatedDate>
29               <ObjectID>2300bb16-bc9b-dd11-be9d-001e0bcf2c98</ObjectID>
30               <CustomerKey>Test2_Key</CustomerKey>
31               <Name>Test2</Name>
32               <Description/>
33               <IsSendable>true</IsSendable>
34               <IsTestable>false</IsTestable>
35               <SendableSubscriberField>
36                  <Name>_SubscriberKey</Name>
37               </SendableSubscriberField>
38            </DestinationObject>
39            <FieldMappingType>MapByOrdinal</FieldMappingType>
40            <FieldMaps>
41               <FieldMap>
42                  <SourceName>1</SourceName>
43                  <DestinationName>EmailId</DestinationName>
44               </FieldMap>
45               <FieldMap>
46                  <SourceName>2</SourceName>
47                  <DestinationName>StatusField</DestinationName>
48               </FieldMap>
49            </FieldMaps>
50            <FileSpec>Test2.csv</FileSpec>
51            <FileType>CSV</FileType>
52            <Notification>
53               <ResponseType>email</ResponseType>
54               <ResponseAddress>help@example.com</ResponseAddress>
55            </Notification>
56            <RetrieveFileTransferLocation>
57               <ObjectID xsi:nil="true"/>
58               <CustomerKey>ExactTarget Enhanced FTP</CustomerKey>
59            </RetrieveFileTransferLocation>
60            <UpdateType>AddAndDoNotUpdate</UpdateType>
61         </Objects>
62      </CreateRequest>
63   </soap:Body>
64</soap:Envelope>

See Also