Unable to delete excluded partition

266 views
Skip to first unread message

road11

unread,
Aug 6, 2014, 11:09:22 AM8/6/14
to adwor...@googlegroups.com
Viewing previous posts on this topic, I've decided it would be easier just to delete my partition tree and create a new one. However, I get an error when I try. I've created operations of type REMOVE in the ProductPartitionHelper.cs class like so (very similar to the ...

        public void CreateRemoveOperation(AdGroupCriterion criterion)
        {
            criterion.adGroupId = this.adGroupId;
            AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
            operation.operand = criterion;
            operation.@operator = Operator.REMOVE;
            this.operations.Add(operation);
        }

Then I get all the Partitions in the adGroup. There are 3 of them in my case: the default partition (type SUBDIVISION), the partition I want to bid on (type UNIT), and the "everything else" partition (also type UNIT). Then I loop through them to create delete operations using the ProductPartitionHelper, followed by the mutate operation, like so...

            List<AdGroupCriterion> list = GetCriteriaForShoppingAdGroup(adGroupID);
            Debug.WriteLine(list.Count);
            ProductPartitionHelper helper = new ProductPartitionHelper(adGroupID); 
            foreach (AdGroupCriterion cri in list)
            {               
                helper.CreateRemoveOperation(cri);
            }           

            AdGroupCriterionService adGroupCriterionService =
                (AdGroupCriterionService)user.GetService(
                AdWordsService.v201406.AdGroupCriterionService);
            try
            {
                adGroupCriterionService.mutate(helper.Operations);
            }            
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                if (ex.InnerException != null)
                {
                    Debug.WriteLine("Inner Exception:" + ex.InnerException.Message);                    
                }
            }

...it chokes on the mutate method with this: Inner Exception:[AdGroupCriterionError.PRODUCT_PARTITION_DOES_NOT_EXIST @ operations[1].operand.criterion.id, AdGroupCriterionError.PRODUCT_PARTITION_DOES_NOT_EXIST @ operations[2].operand.criterion.id]

the third partition in this tree, the "everything else" partition, (the one represented by operations[2]) is excluded, hence the Google API gave it a type of NegativeAdGroupCriterion (criterionUse = "NEGATIVE"). 

So, since it thinks this partition doesn't exist, I tried passing only the first two, omitting the 3rd. When I do that, I get the same error:
Inner Exception:[AdGroupCriterionError.PRODUCT_PARTITION_DOES_NOT_EXIST @ operations[1].operand.criterion.id]

...that operation is represented by the real product I'm bidding on, and it most assuredly does exist. I can verify this by downloading the report from the UI for the adGroup and comparing criterion ID's. It's definitely a product partition with a criterion type of BIDDABLE.

Finally, I tried removing just the root partition. I had seen earlier Josh indicated that removing that partition performs a cascading delete. However, when I do that, I get this exception: 
Inner Exception:[OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE @ operations[0].operand.userStatus; trigger:'SHOPPING', OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE @ operations[0].operand.biddingStrategyConfiguration.biddingScheme; trigger:'SHOPPING', OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE @ operations[0].operand.biddingStrategyConfiguration.biddingStrategyType; trigger:'SHOPPING']


 So, can somebody from the adwords team set me straight? How do you delete a partition tree out of an adGroup through the API that contains an excluded partition (all of ours do)? It doesn't seem to like anything I throw at it.

Eric


Sérgio Gomes (Shopping API Team)

unread,
Aug 8, 2014, 6:57:40 AM8/8/14
to adwor...@googlegroups.com
Hi Eric,

I'm afraid I'm having trouble replication your issue locally. I've set up a partition tree with a NegativeAdGroupCriterion and had no trouble deleting the whole thing by just deleting the base node.

Perhaps the tree you're testing this with is in an inconsistent state? Could you try creating a new one and testing there?

Cheers,
Sérgio

---
Sérgio Gomes
Developer Relations

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Registered in England Number: 3977902

road11

unread,
Aug 8, 2014, 10:05:33 PM8/8/14
to adwor...@googlegroups.com
Sergio,

Thanks for your response. In all of my trees, I have only 3 partitions: the default subdivision partition, the sku partition that I bid on (type UNIT), and the "everything else" partition, which I've set up to be Excluded, making it a NegativeAdGroupCriterion, which is also a UNIT type. I can't seem to delete any of them successfully. Are you saying you're deleting the default "all products" partition? That partition's ID seems to be shared among all my adGroups (all my adGroups' default partitions have that same ID).

If my tree were in an inconsistent state, how would I know? It looks the same in the UI as it does had I created it in the UI, itself. Would it help if I posted the C# code I used to create the tree?

Eric

Sérgio Gomes (Shopping API Team)

unread,
Aug 11, 2014, 4:32:43 AM8/11/14
to adwor...@googlegroups.com
Hi Eric,

Yes, I'm deleting the default subdivision partition. The ID is shared among all ad groups, as you say, but remember that by deleting an ad group criterion you're deleting inside a specific ad group (AdGroupCriterion.mutate takes both the ad group ID and the criterion ID), so you won't be deleting anything in other ad groups.

As for the tree being in an inconsistent state, that doesn't seem to be the case, since you can see it in the UI (you'd be getting errors otherwise), so it's probably just a case of deleting the root node and calling it a day.

Cheers,
Sérgio

---
Sérgio Gomes
Developer Relations

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Registered in England Number: 3977902

road11

unread,
Aug 14, 2014, 10:13:04 AM8/14/14
to adwor...@googlegroups.com
Sergio,

Thank you for your kind response. Is there any way you could please post your C#.Net code (or VB.Net, for that matter) that you are using to get this done? No matter what I throw at it, I keep getting an error message saying I am not allowed to perform this operation for a Shopping campaign. 

And could you please pass along to the dev team how frustrating it is to have code samples that do not show how to perform edits and deletes? Shopping is the first API Google has ever released that did not provide the entire CRUD (create, read, update, delete) spectrum in the published sample code. There would be far fewer questions on the forums if they would have done that very basic thing.

Thanks,

Eric

Sérgio Gomes (Shopping API Team)

unread,
Aug 14, 2014, 12:26:08 PM8/14/14
to adwor...@googlegroups.com
Hi Eric,

I'm afraid I ran my tests in a different programming language, namely Ruby. In any case, it's a simple case of constructing a mutate request for the AdGroupCriterion, with

operation: "REMOVE"
operand: a BiddableAdGroupCriterion with the adGroupId set to the ad group ID in question, and a criterion with the id set to the criterion ID in question. In (hopefully readable) Ruby:

operation = {
  :operator => 'REMOVE',
  :operand => {
    :xsi_type => 'BiddableAdGroupCriterion',
    :ad_group_id => ad_group_id,
    :criterion => {
      :id => criterion_id
    }
  }
}

If you're still getting errors after replicating the above in .NET let me know and I'll contact you privately so we can look at your SOAP logs.

As for the sample code, it's my team that writes it, and I'm sorry to hear you found it lacking. We'll see what you can do about providing some more samples for the Shopping use cases.

Cheers,
Sérgio

---
Sérgio Gomes
Developer Relations

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Registered in England Number: 3977902

road11

unread,
Aug 15, 2014, 1:16:11 PM8/15/14
to adwor...@googlegroups.com
Thanks for this, Sergio. It worked for me; just delete it the same way you would a keyword. Way easier than what I was trying to do.

Eric

road11

unread,
Aug 26, 2014, 1:40:17 PM8/26/14
to adwor...@googlegroups.com
Sergio,

Any chance you could post your code (even if it's Ruby) to edit the CaseValue of a partition? I can't seem to find a combination that works for me without throwing an exception.

Thanks in advance,

Eric

Sérgio Gomes (Shopping API Team)

unread,
Aug 27, 2014, 6:26:57 AM8/27/14
to adwor...@googlegroups.com
Hi Eric,

I suspect that the issue is you can't change the CaseValue for a node, since that's part of the identity of the object and would essentially mean changing its ID (and by extension, the IDs of the nodes below it). You'll likely have to remove that node (thus deleting the entire subtree underneath it), and reinsert the node and subtree without any IDs, in order to rebuild it correctly.

I'll run some tests locally to make sure this is the case, though, and will let you know.

Cheers,
Sérgio

---
Sérgio Gomes
Developer Relations

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Registered in England Number: 3977902


Reply all
Reply to author
Forward
0 new messages