0

I’m trying to retrieve subscribers using a filter on the attribute called “FirstName” via SOAP API. “FirstName” attribute is there in the Marketing Cloud instance.

When I try to use the retrieve method which mentioned here and as below code, I get an Error saying “invalid column name”. I double check the attribute names which used in my filter, it seems correct.

        APIObject[] Results;
        String requestID;
        String status;

        RetrieveRequest rr = new RetrieveRequest();
        rr.ObjectType = "Subscriber";//required

        SimpleFilterPart sf = new SimpleFilterPart();
        sf.SimpleOperator = SimpleOperators.equals;
        sf.Property = "FirstName";
        sf.Value = new String[] { "Joe" };

        rr.Filter = sf;

        rr.Properties = new string[] { "ID" };
        status = client.Retrieve(rr, out requestID, out Results);

Are there any constrains which we cannot use the subscriber attributes as a filter or is there any convenient way to filter subscribers using attributes?

0

I looked at your code and then compared it with the sample/example in the salesforce marketing cloud developer documentation.

I think if you need to grab the FirstName attribute from the Subscriber object type you need to define it in your code.

This is just an example of what you're missing in your code. Here is the modified example code from the documentation:

public void testRetrieveSubcriberByKey() throws RemoteException {
    Soap stub = init();
    RetrieveRequest request = new RetrieveRequest();
    request.setObjectType("Subscriber");
    String[] props = { "ID", "SubscriberKey", "FirstName" };
    request.setProperties(props);
    request.setQueryAllAccounts(true); //scans all sub-Accounts of parent-Account
    //Query filter using Simplefilter.
    SimpleFilterPart filterPart = new SimpleFilterPart();
    filterPart.setProperty("FirstName");
    String[] values = {"Joe"};
    filterPart.setValue(values);
    filterPart.setSimpleOperator(SimpleOperators.equals);
    request.setFilter(filterPart);
    RetrieveRequestMsg requestMsg = new RetrieveRequestMsg();
    requestMsg.setRetrieveRequest(request);
    RetrieveResponseMsg responseMsg = stub.retrieve(requestMsg);  //Soap call to request Account object
    assertNotNull(responseMsg);
    assertNotNull(responseMsg.getResults(0));
    Subscriber sub = (Subscriber) responseMsg.getResults(0);
    if(sub!=null && sub.getAttributes()!=null && sub.getAttributes().length >0){
        Attribute[] a = sub.getAttributes();
        for(int i=0; i< sub.getAttributes().length-1; i ++) {
        Attribute a1 = sub.getAttributes(i);
        System.out.println("Name :: " + a1.getName() + "  Value :: " + a1.getValue());
        }
    }
}
  • I tried adding "FirstName" to the properties list as you suggested in the above code. But its not working. As I can see, we can only add filters to the "Properties". Not for the "Attributes". – Ashan Aug 3 '17 at 4:06

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.