I am selecting a group of Budgets, then REMOVING them from the 
BudgetService.

The code to select  and then remove these Budgets is (C#):

            //Google API variables
            BudgetService budgetService_C = null;
            Budget budget_C = null;
            BudgetOperation budgetOperation_C = null;
            Selector selectorBudget_C = null;
            Predicate predicateBudget_C = null;


                            // Create the selector.
                            selectorBudget_C = new Selector();
                            selectorBudget_C.fields = new string[] { 
"BudgetId", "BudgetName" };

                            // Create the filters.
                            predicateBudget_C = new Predicate();
                            predicateBudget_C.field = "BudgetName";
                            predicateBudget_C.@operator = 
PredicateOperator.NOT_EQUALS;
                            //predicateBudget_C.@operator = 
PredicateOperator.EQUALS;
                            predicateBudget_C.values = new string[] { 
campaign_C.budget.name.ToString() };
                            selectorBudget_C.predicates = new Predicate[] { 
predicateBudget_C };

                            // Set the selector paging.
                            selectorBudget_C.paging = new Paging();

                            // Initializations 
                            offset = 0;
                            pageSize = 1000;

                            budgetPage_C = new BudgetPage();

                            try
                            {
                                // Loop over these budgets till finished
                                do 
                                {
                                    selectorBudget_C.paging.startIndex = 
offset;
                                    selectorBudget_C.paging.numberResults = 
pageSize;

                                    // Get the the Budgets for this 
Campaign, there should only be one.
                                    budgetPage_C = 
budgetService_C.get(selectorBudget_C);

                                    // Is there more than one matching 
budget for this campaign?
                                    if (budgetPage_C.totalNumEntries >= 1)
                                    {
                                        //Get the one matching Budget for 
this Campaign
                                        // Display the results.
                                        if (budgetPage_C != null && 
budgetPage_C.entries != null)
                                        {
                                            int i = offset;
                                            foreach (Budget budget in 
budgetPage_C.entries)
                                            {
                                                // Remove all Budgets with 
the same BudgetName
                                                budget2_C = budget;

                                                budgetOperation_C = new 
BudgetOperation();
                                                budgetOperation_C.@operator 
= Operator.REMOVE;
                                                budgetOperation_C.operand = 
budget2_C;

                                                // Now perform the REMOVE 
Budget BudgetOperation
                                                try
                                                {
                                                    BudgetReturnValue 
budgetRetval = budgetService_C.mutate(new BudgetOperation[] { 
budgetOperation_C });
                                                    budget_C = 
budgetRetval.value[0];
                                                }
                                                catch (Exception ex)
                                                {
                                                    throw new 
System.ApplicationException("Failed to REMOVE duplicate BudgetName cases. - 
ADM.", ex);
                                                }

                                                i++;
                                            }
                                        }
                                        else
                                        {
                                            throw new 
System.ApplicationException("Failed to retrieve Campaign's matching Budget, 
there should be one matching case. - ADM.");
                                        }
                                        offset += pageSize;

                                    }
                                } while (offset < 
budgetPage_C.totalNumEntries);
                            }
                            catch (Exception ex)
                            {
                                throw new 
System.ApplicationException("Failed to retrieve Budgets matching 
BudgetName.", ex);
                            }

This is producing in most cases an exception with message:

    {"[BudgetError.BUDGET_DELETED @ operations[0].operand]"}

What does this mean?

How is this code incorrect?  Can I not delete Budgets from a BudgetService?

Any help is appreciated.

Thanks,
Bryan

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to