salesforce-marketingcloud / FuelSDK-Python

FuelSDK for python
Other
127 stars 193 forks source link

CRUD with Import Definitions #62

Open tdsticks opened 8 years ago

tdsticks commented 8 years ago

We're having issues trying to create Import Definitions with the FuelSDK for Python. We've managed to add another class in the objects.py class. Which allows us to read and delete.

class ET_Import(ET_CUDSupport):
    def __init__(self):
        super(ET_Import, self).__init__()
        self.obj_type = 'ImportDefinition'

However, when we try to create an Import Definition, it returns with this error:

post_response:  <FuelSDK.rest.ET_Post object at 0x1098f41d0>
code: 200
results: [(CreateResult){
   StatusCode = "Error"
   StatusMessage = "ID of the custom object cannot be empty."
   OrdinalID = 0
   ErrorCode = 43040
   NewID = 0
   Object = 
      (ImportDefinition){
         PartnerKey = None
         ObjectID = None
         CustomerKey = "000001-22222-33333-44444-55555-66666"
         Name = "Aaaaaaaaaaaaaaaaaaaaaaaa"
         Description = "This is a test from Python"
         AllowErrors = True
         DestinationObject = 
            (APIObject){
               PartnerKey = None
               ID = 463703
               ObjectID = None
            }
         FieldMappingType = "InferFromColumnHeadings"
         FileSpec = "file_that_is_on_the_ftp.csv",
         FileType = "Other"
         Notification = 
            (AsyncResponse){
               ResponseType = "email"
               ResponseAddress = "my email address}"
            }
         RetrieveFileTransferLocation = 
            (FileTransferLocation){
               PartnerKey = None
               ObjectID = None
               CustomerKey = "ExactTarget Enhanced FTP"
            }
         SubscriberImportType = "Email"
         UpdateType = "AddAndUpdate"
         Delimiter = ";"
      }
 }]
status: False

Here's what our call looks like:

def create_import_def(self):
        create_imp_def = FuelSDK.ET_Import()
        create_imp_def.auth_stub = self.myClient

        list_id = 463703

        create_imp_def.props = {
            "CustomerKey": "000001-22222-33333-44444-55555-66666",
            "Name": "Aaaaaaaaaaaaaaaaaaaaaaaa",
            "Description": "This is a test from Python",
            "DestinationObject": {
                "ID": list_id
            },
            "AllowErrors": True,
            "Notification": {
                "ResponseType": "email",
                "ResponseAddress": "{my email address}"
            },
            "RetrieveFileTransferLocation": {
                "CustomerKey": "ExactTarget Enhanced FTP"
            },
            "UpdateType": "AddAndUpdate",

            "FieldMappingType": "InferFromColumnHeadings",
            "FileSpec": "file_that_is_on_the_ftp.csv",
            "FileType": "Other",
            "Delimiter": ";",
            "SubscriberImportType": "Email"
        }

        post_response = create_imp_def.post()
        print 'post_response: ', post_response

        print "code:", post_response.code
        #print "message:", post_response.message
        #print "more_results:", post_response.more_results
        #print "request_id", post_response.request_id
        print "results:", post_response.results
        print "status:", post_response.status

We've tried many different attempts to get this to work changing out various fields and values. We've even tried to manipulate the XML SOAP envelope to match what the FuelSDK-PHP uses before its sent out, but no luck.

papaben commented 8 years ago

I don't remember exactly, but I recall that the examples in the documentation reference an outdated WSDL schema. If your SOAP envelope matches those produced by those examples and my memory is correct, then it's possible that it's not what is expected by the SOAP API.