salesforce-marketingcloud / FuelSDK-Java

Salesforce Marketing Cloud Java SDK
BSD 3-Clause "New" or "Revised" License
73 stars 122 forks source link

Unable to Delete Row #12

Closed ccrawford93 closed 9 years ago

ccrawford93 commented 10 years ago

I am currently running on revision 665107845a84be24c5fefd128ad88d2cc80a03b8. If any of this will be fixed in an upcoming release, please let me know.

As of now, I have no way to delete a row in any data extension. Here is my code:

String deName = "Test DE";
        ETFilter deFilter = new ETSimpleFilter("Name", ETFilterOperators.EQUALS, deName);

        ETDataExtension dataExtension;
        try {
            dataExtension = client.retrieveDataExtension(deFilter);
        } catch (ETSdkException e) {
            throw new Exception(String.format("There was no matching data extension with the provided name. Name: %s", deName));
        }

        ETFilter rowFilter = new ETSimpleFilter("Email Address", ETFilterOperators.EQUALS, "clientTest@gmail.com");

List<ETResult> results;
        try {
            results = dataExtension.delete(rowFilter);
        } catch (ETSdkException e) {
            throw new Exception(String.format("There was an error deleting the row for the data extension. ExtensionName: %s", deName), e);
        }

These calls result in an error code of 310007 and a message of "Keys Not Found". I have also tried utilizing the deprecated service, in addition to trying to use the deprecated setter for "Keys" but have had no success:

// Deprecated stuff fails as well
        List<ETDataExtensionRow> rowList = dataExtension.select(rowFilter);
        Map<String, String> blah = new HashMap<String, String>();
        blah.put("Email Address", "clientTest@gmail.com");
        rowList.get(0).setKeys(blah);
        ETResponse<ETResult> response;
        try {
            rowList.get(0).setName(deName);
            response = dataExtensionRowService.delete(client, rowList.get(0));
        } catch (ETSdkException e){
            throw new Exception(String.format("There was error deleting the row for the data extension. ExtensionName: %s", deName));
        }

Furthermore, I have found a related issue in the ruby sdk that could potentially be related given the "properties/property" vs "keys/key". http://salesforce.stackexchange.com/questions/33398/fuel-sdk-ruby-client-delete-a-row-from-a-data-extension

Is this an issue of needing to be refactored, not using the calls in the correct manner, or not using the most recent version of the sdk (which is broken, see other issue I've created). Any information would be helpful.

PS: To be clear, all of the objects and their names are correct and return the corresponding object back to my client. I have traced the issue directly until the point in which the SOAP call is made.

shivramkrish commented 10 years ago

Even i'm facing similar issue - Rows in Data Extension Not being deleted. Running on Fuel Java SDK v0.999999-pre1.0-2.

Code snippet :

try { ETResponse response = client.retrieve(ETDataExtension.class, "name='test DE'"); ETDataExtension extension = response.getResults().get(0);

ETDataExtensionRow row = new ETDataExtensionRow(); row.setColumn("Email", "test@gmail.com");

System.out.println("delete row = " + extension.delete(row)); } catch (ETSdkException e) { e.printStackTrace(); }

Log :

delete row = [com.exacttarget.fuelsdk.ETResult[requestId=null,statusCode=Error,statusMessage=Keys Not Found,errorCode=70000,id=null,guid=null]]

Can someone please help me resolve this issue?

ccrawford93 commented 9 years ago

I'm not positive this will work, but use the underlying "*interal" package that includes all the SOAP objects and just use the SOAP api for it. I'm using it for other various items that are missing from the sdk and it seems to work fine.

     TriggeredSend send = new TriggeredSend();
        TriggeredSendDefinition definition = new TriggeredSendDefinition();
        SendClassification sendClassification = new SendClassification();

        sendClassification.setName("Default Commercial");
        sendClassification.setCustomerKey("Default Commercial");
        definition.setSendClassification(sendClassification);
        definition.setName(sendRequest.getName());
        definition.setCustomerKey(sendRequest.getCustomerKey());
        send.setTriggeredSendDefinition(definition);

        List<com.exacttarget.fuelsdk.internal.Subscriber> subscriberList = new ArrayList<com.exacttarget.fuelsdk.internal.Subscriber>();
        for (String subscriberKey : sendRequest.getSubscriberKeyList()) {
            com.exacttarget.fuelsdk.internal.Subscriber sub = new com.exacttarget.fuelsdk.internal.Subscriber();
            sub.setSubscriberKey(subscriberKey);

            subscriberList.add(sub);
        }
        send.getSubscribers().addAll(subscriberList);

        CreateRequest createRequest = new CreateRequest();
        createRequest.setOptions(new CreateOptions());
        APIObject object = send;
        createRequest.getObjects().add(object);
        CreateResponse createResponse = soap.create(createRequest);

Just replace TriggeredSend with whatever you're trying to delete (ie: Subscriber) and the CreateRequest/Options/Response with the corresponding delete objects. Use this as a guide and you should be able to take care of anything you need using this manner of code:

https://help.exacttarget.com/en/technical_library/web_service_guide/

shivramkrish commented 9 years ago

Thanks for your response. Developer guide gave me good view of using the SOAP objects and api and tried to implement the same, now I'm able to delete the data extension rows.

Thanks for your guidance on this issue.

matrostik commented 6 years ago

Wow the issue still exits