I'm trying to create a FilterDefinition via the API. I saw that a few years back, Michael Allen Clark had said that this feature was not built into the FuelSDK. I think he was specifically talking about SimpleFilterParts. This post had helped me in the past:
And I SOAP encoded my filters. That allowed me to retrieve data extensions with more than one filter, but this time, I am trying to create using a POST. I know MAC said it wasn't built in, but just based on what I know about the SDK and the fact that it worked for a retrieve, makes me think I should be able to get it working now. It's a pretty simple FilterDefinition. I am not even trying to use Complex Filters. Here is my code:
$de = new ET_DataExtension(); $de->CustomerKey = 'external-key'; $post = new ET_FilterDefinition(); $post->authStub = unserialize($_SESSION['client']); $f = new SoapVar(array('Property' => 'TeamMemberRole','SimpleOperator' => 'contains','Value' => 'Manager'), SOAP_ENC_OBJECT, 'SimpleFilterPart', "http://exacttarget.com/wsdl/partnerAPI"); $post->props = array( "Name" => "Test Filter", "CustomerKey" => "Test Filter", "DataSource" => $de, "DataFilter" => $f ); $p = $post->post();
I have tried this so many different ways. The Fuel SDK generally takes properties as a naked array, like this
"DataFilter" => array('Property' => 'TeamMemberRole','SimpleOperator' => 'contains','Value' => 'Manager')
But that doesn't work either. I feel like I've tried every possible combination, but I keep getting the error 'The DataFilter that was provided is invalid.'
I feel like I must be getting through to the API because when I omit the DataFilter I get 'DataFilter is required for Create calls.'.
Maybe I just don't really understand the FuelSDK, but I feel like this should work. I suppose the other option is to just include the exacttarget soap file and go straight to the API, but I feel like I'm sooo close. Any suggestions?
UPDATE: I can get it to work using ET_List and All Subscribers. So it appears to be some fault with using a data extension.
Another update. It appears to be an issue with how I'm setting up the data extension object. When I tried it using "First Name", a profile attribute, it worked and created a DataFilter that was based on profile attributes. So even though I was trying to use a DE as a source, it still went to profile attributes. So I must be doing something wrong there. So I think this is my main issue. It's defaulting to profile attributes and the fields I'm trying to use from my source DE are causing an error because they are NOT profile attributes.