1

I'm using the following code to create a list, upload a CSV to FTP and create an import definition....

    list = do_add_list "Temp List for #{delivery["message_id"]}"
    raise Exception.new("Unable to create delivery list") if list.has_key? :results and list[:results][:is_error]
    list_id = list[:results][:id].to_i

    # write recipients to tmp CSV
    file_name = "#{SecureRandom.uuid}.csv"
    File.open(file_name, "w") do |csv|
      csv << "Subscriber Key,Status,Email Address\n"
      delivery["emails"].each do |email|
        valid = ValidatesEmailFormatOf::validate_email_format(email)
        if not valid.nil?
          csv << "#{email},Active,\n" if not email.empty?
        else
          csv << ",Active,#{email}\n" if not email.empty?
        end
      end
    end

    # upload temp CSV to FTP
    Net::FTP.open(ftp_host, ftp_username, ftp_password) do |ftp|
      ftp.chdir('Import')
      ftp.puttextfile(File.new(file_name))
    end

    # create import definition
    import = FuelSDK::Import.new
    import.client = client.client
    import.properties = {
      "Name"=> "Temp List for test",
      "CustomerKey" => "TEMPIMPORT1",
      "Description" => "SDK Generated Import",
      "AllowErrors" => "true",
      "DestinationObject" => {"ID" => list_id},
      "FieldMappingType" => "InferFromColumnHeadings",
      "FileSpec" => file_name,
      "FileType" => "CSV",
      "RetrieveFileTransferLocation" => {"CustomerKey" => "ExactTarget Enhanced FTP"},
      "UpdateType" => "AddAndUpdate"
    }
    resp = import.post

    unless resp.status
      raise "Unable to create import definition due to: #{resp.results[0][:status_message]}"
    end

    # start import
    import_status = ""
    import = import.start
    while import.status && import_status != "Error" && import_status != "Completed" do
      # wait a bit before checking the status to give it time to process
      sleep 15
      import_status = import.status.results[0][:import_status]
    end

    unless import_status == "Completed"
      raise "Unable to import subscribers to list: #{import_status}"
    end

This code is using ExactTarget's own FuelSDK ruby client and is based on their provided CreateAndStartListImport method for creating an import definition from a file uploaded to FTP.

When I run this code, the list is successfully created and the CSV file is successfully uploaded to the FTP site (manually verified). However, it fails when submitting the POST request to create the import definition, responding with the error message "ID of the custom object cannot be empty”.

The response from the POST shows that a valid filename and list id were submitted...

2.1.0 :532 > resp.results[0][:object] => {:partner_key=>nil, :object_id=>nil, :customer_key=>"TEMPIMPORT1", :name=>"Temp List for test", :description=>"SDK Generated Import", :allow_errors=>true, :destination_object=>{:partner_key=>nil, :id=>"2032991", :object_id=>nil}, :field_mapping_type=>"InferFromColumnHeadings", :file_spec=>"emailimport.csv", :file_type=>"CSV", :retrieve_file_transfer_location=>{:partner_key=>nil, :object_id=>nil, :customer_key=>"ExactTarget Enhanced FTP"}, :update_type=>"AddAndUpdate", :"@xsi:type"=>"ImportDefinition”}

Can anyone provide more details on the cause and resolution for this error, especially since it's using the same code from ExactTarget's own ruby client library.

  • What environment is your account, and is the FTP location teh Exacttarget Enhanced FTP? – Kelly J Andrews Jan 1 '15 at 7:37
  • I believe we're still on the sandbox environment and using ftp.s7.exacttarget.com. "Exacttarget Enhanced FTP" is the key meant to indicate where the file has been uploaded and is provided by the SDK in the CreateAndStartListImport link I posted. – Matt Jan 2 '15 at 17:54
  • Sandbox as in developer edition? – Kelly J Andrews Jan 2 '15 at 17:54
  • Not sure. How can I find out? – Matt Jan 2 '15 at 17:55
  • How did you get your account and ftp credentials? – Kelly J Andrews Jan 2 '15 at 17:56
1

This error results when you Marketing Cloud can't find the List/DataExtension referred to in the Destination section of your object. The options are ID (Object ID) or CustomerKey - i have not had any success using ID. Try using the CustomerKey (External Key) and set ObjectID = null.

This is what my payload looks like:

"Object": {
   "PartnerKey": null,
   "ObjectID": "36ad***-*****-****-***85b9", <-- generated by SFMC
   "CustomerKey": "tx1_Contact",
   "Name": "tx1_Contact",
   "Description": "tx1_Contact Created by API createImportActivity",
   "AllowErrors": true,
   "DestinationObject": {
     "PartnerKey": null,
     "ObjectID": null,
     "CustomerKey": "Contact"
   },
   "FieldMappingType": "InferFromColumnHeadings",
   "FileSpec": "ZZ_API_FILE_001.csv",
   "FileType": "CSV",
   "RetrieveFileTransferLocation": {
     "PartnerKey": null,
     "ObjectID": null,
     "CustomerKey": "ExactTarget Enhanced FTP"
   },
   "UpdateType": "AddAndUpdate"
 }

Im my case i have a data extension with the External Key: Contact and this works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.