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.