Campaign budget gives DUPLICATE_NAME error even the previous campaign and campaign budget with same name has been removed

110 views
Skip to first unread message

Divya Patel

unread,
Jul 31, 2023, 2:36:53 AM7/31/23
to Google Ads API and AdWords API Forum
I am using "mutateResources()" method to create my campaign budget and campaign.

I create a campaign and then delete that campaign from the google ads website. I do this for like 2 times and everything works properly. But after the 2nd (or 3rd - not sure) time, it threw this error. (note that the campaign is removed so I guess the campaign budget should also be removed. even so, it gives this error).

{
    "error_code": {
        "campaign_budget_error": "DUPLICATE_NAME"
    },
    "message": "A campaign budget with this name already exists.",
    "trigger": {
        "string_value": "ABC Budget"
    },
    "location": {
        "field_path_elements": [
            {
                "field_name": "mutate_operations",
                "index": 0
            },
            {
                "field_name": "campaign_budget_operation"
            },
            {
                "field_name": "create"
            },
            {
                "field_name": "name"
            }
        ]
    }
}

so I tried to remove the campaign budget using an API. I refer to this document https://developers.google.com/google-ads/api/docs/campaigns/budgets/remove-budgets
 and I also confirmed that the reference_count is 0.

const [getBudgetResourceName] = await customer.query(`
        SELECT
            campaign_budget.resource_name,
            campaign_budget.reference_count,
            campaign_budget.status
        FROM
            campaign_budget
        WHERE
            campaign_budget.name = '${campaignBudgetName}'
    `);

const remove = {
            entity: "campaign_budget",
            operation: "update",
            resource: getBudgetResourceName.campaign_budget.resource_name,
        };

after this the status of that campaign budget changes from ENABLED/PAUSED to REMOVE.

after this, I am trying to create a new campaign budget with the same name. It still gives the same error.

{
    "error_code": {
        "campaign_budget_error": "DUPLICATE_NAME"
    },
    "message": "A campaign budget with this name already exists.",
    "trigger": {
        "string_value": "ABC Budget"
    },
    "location": {
        "field_path_elements": [
            {
                "field_name": "mutate_operations",
                "index": 0
            },
            {
                "field_name": "campaign_budget_operation"
            },
            {
                "field_name": "create"
            },
            {
                "field_name": "name"
            }
        ]
    }
}

So, can you please help me with this? What is the correct way to delete a campaign budget? Or if there is any condition that needs to be checked?

Divya Patel

unread,
Jul 31, 2023, 2:38:59 AM7/31/23
to Google Ads API and AdWords API Forum
My mistake with the removal operation. I used this 👇. 

const remove = {
            entity: "campaign_budget",
            operation: "remove",
            resource: getBudgetResourceName.campaign_budget.resource_name,
        };

still the error is there.

Divya Patel

unread,
Jul 31, 2023, 3:27:10 AM7/31/23
to Google Ads API and AdWords API Forum
Okay. So I think I understand where the issue is.

I was creating a shared budget. so I have to delete the budget from the shared budget list every time. 

I added this field when I create a campaign budget which solved the issue for me.

`explicitly_shared: false,`

const budget: MutateOperation<resources.ICampaignBudget>[] = [
        {
            entity: "campaign_budget",
            operation: "create",
            resource: {
                resource_name: budgetResourceName, // Create a budget with the temporary resource id
                name: campaignBudgetName,
                delivery_method: enums.BudgetDeliveryMethod.STANDARD,
                amount_micros: toMicros(10),
                explicitly_shared: false,
            },
        },
    ];

Google Ads API Forum Advisor

unread,
Jul 31, 2023, 7:33:19 AM7/31/23
to divyapa...@gmail.com, adwor...@googlegroups.com
Hello Divya,

Thank you for reaching out to us.

We're glad that your issue has been resolved. However, should you encounter any problems in the future, feel free to reach back to us and we'd be happy to provide you assistance.
 
This message is in relation to case "ref:_00D1U1174p._5004Q2mxT1p:ref"

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages