Hello,
I'm trying to create a video campaign using the Google Ads API, based on
the documentation for Campaigns in version 13:
https://developers.google.com/google-ads/api/reference/rpc/v13/Campaign.
I'm also referencing the video channel type documentation here:
https://developers.google.com/google-ads/api/reference/rpc/v13/AdvertisingChannelTypeEnum.AdvertisingChannelType
.
However, when I try to create my campaign, I'm encountering an error.
{
"message": "Request contains an invalid argument.",
"code": 3,
"status": "INVALID_ARGUMENT",
"details": [
{
"@type":
"type.googleapis.com\/google.ads.googleads.v13.errors.GoogleAdsFailure",
"errors": [
{
"errorCode": {
"mutateError": "MUTATE_NOT_ALLOWED"
},
"message": "Mutates are not allowed for the requested
resource.",
"trigger": {
"stringValue": "VIDEO"
},
"location": {
"fieldPathElements": [
{
"fieldName": "operations",
"index": 0
}
]
}
},
{
"errorCode": {
"contextError":
"OPERATION_NOT_PERMITTED_FOR_CONTEXT"
},
"message": "The operation is not allowed for the given
context.",
"trigger": {
"stringValue": "MANUAL_CPC"
},
"location": {
"fieldPathElements": [
{
"fieldName": "operations",
"index": 0
},
{
"fieldName": "create"
},
{
"fieldName": "manual_cpc"
}
]
}
}
],
"requestId": "vyH2QzTeEcbk6SNicNHJrA"
}
]
}
My Code is
try {
// Creates a single shared budget to be used by the campaigns added below.
$budgetResourceName = $this->addCampaignBudget($customerId, $refreshToken);
$budgetResourceName = json_decode($budgetResourceName->getContent(),true);
// Configures the campaign network options.
$networkSettings = new NetworkSettings([
'target_google_search' => true,
'target_search_network' => true,
'target_content_network' => true,
'target_partner_search_network' => true
]);
$campaignOperations = [];
$params['name'] = 'VIDEO Campaign';
$params['advertising_channel_type'] = AdvertisingChannelType::VIDEO;
$params['manual_cpc'] = new ManualCpc();
$params['campaign_budget'] = $budgetResourceName['response'];
$params['network_settings'] = $networkSettings;
$params['start_date'] = date('Ymd', strtotime('+1 day'));
$params['end_date'] = date('Ymd', strtotime('+1 month'));
$campaign = new Campaign($params);
// Creates a campaign operation.
$campaignOperation = new CampaignOperation();
$campaignOperation->setCreate($campaign);
$campaignOperations[] = $campaignOperation;
// Issues a mutate request to add campaigns.
$googleAdsClient = $this->googleAdsClient($refreshToken);
$campaignServiceClient = $googleAdsClient->getCampaignServiceClient();
$response = $campaignServiceClient->mutateCampaigns($customerId,
$campaignOperations);
foreach ($response->getResults() as $addedCampaign) {
$addedCampaignResult = $addedCampaign->getResourceName();
}
$resultResponse = [];
if($addedCampaignResult) {
$resultResponse['name'] = $addedCampaignResult;
$resultResponse['status'] = CampaignStatus::PAUSED;
preg_match('/customers\/(\d+)/', $addedCampaignResult, $matches);
$resultResponse['customerId'] = $matches[1];
// Extract campaign ID
preg_match('/campaigns\/(\d+)/', $addedCampaignResult, $matches);
$resultResponse['campaignId'] = $matches[1];
$resultResponse['id'] = $matches[1];
}
return response()->json(['status' => 1, 'response' => $resultResponse]);
} catch (ApiException $apiException) {
return response()->json(['status' => 0, 'error' =>
$apiException->getMessage(), 'errorMessage' => $apiException->getMessage(),
'error_type' => 'campaign', 'response' => null]);
}
- I would like to confirm whether video campaigns are supported in the
Google Ads API or not.
-
- Is the video campaign feature still in beta version of Google Ads API?
Could this be the reason why I am getting the error "A mutate action is not
allowed on this resource, from this client"?
-
- If the video campaign feature is in beta, how can I request access to
the beta version?
-
- I noticed that I only have basic API access. If I request standard API