Unable to create a campaign budget

104 views
Skip to first unread message

Jerome Wilson

unread,
Jun 17, 2022, 6:42:24 AM6/17/22
to Google Ads API and AdWords API Forum
I'm trying to create a campaign budget using the PHP client and code that is pretty much exactly the same as the example in the documentation but it's returning an error. Other API calls are working fine.

The error returned is:

Google\Ads\GoogleAds\Lib\V10\GoogleAdsException: {
    "message": "Request contains an invalid argument.",
    "code": 3,
    "status": "INVALID_ARGUMENT",
    "details": [
        {
            "@type": "google.ads.googleads.v10.errors.googleadsfailure-bin",
            "data": "<Unknown Binary Data>"
        },
        {
            "@type": "grpc-status-details-bin",
            "data": "<Unknown Binary Data>"
        },
        {
            "@type": "request-id",
            "data": "1FiGZJWMT2KvWD68UtgPUQ"
        }
    ]
}


The code I'm using is:

function addCampaignBudget(GoogleAdsClient $googleAdsClient, int $customerId)
{
    // Creates a campaign budget.
    $budget = new CampaignBudget([
        'name' => 'Default budget',
        'delivery_method' => BudgetDeliveryMethod::STANDARD,
        'amount_micros' => 500000
    ]);

    // Creates a campaign budget operation.
    $campaignBudgetOperation = new CampaignBudgetOperation();
    $campaignBudgetOperation->setCreate($budget);

    // Issues a mutate request.
    $campaignBudgetServiceClient = $googleAdsClient->getCampaignBudgetServiceClient();
    $response = $campaignBudgetServiceClient->mutateCampaignBudgets(
        $customerId,
        [$campaignBudgetOperation]
    );

    return $response->getResults()[0]->getId();
}

Any help with this would be much appreciated. Thanks.

Jerome Wilson

unread,
Jun 17, 2022, 12:25:42 PM6/17/22
to Google Ads API and AdWords API Forum
I've found more detailed messages in the log - it turned out it was a DUPLICATE_NAME.

Google Ads API Forum Advisor

unread,
Jun 17, 2022, 2:57:50 PM6/17/22
to jerome...@gmail.com, adwor...@googlegroups.com
Hi Jerome,

Thank you for reaching out to the Google Ads API support team.

To investigate the issue further, could you please provide the complete request and response logs, with the request-id? If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link.You can provide it via Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead. Let me know if you have any questions.

Thanks,
Google Logo
Nirmitabahen Gaurav
Google Ads API Team
 


ref:_00D1U1174p._5004Q2bxMvI:ref
Reply all
Reply to author
Forward
0 new messages