For the past three days I have been trying to get Campaign creation for 
Universal App Campaigns working on my test MCC account. My client is 
programmed in PHP I have added the code below. I am using the Google Client 
API for PHP to do my requests via GRPC.
I have followed the following guide to get the right settings for a 
Universal App Campaign: 
https://developers.google.com/google-ads/api/docs/app-campaigns/create-campaign

I have tried:

   - Removing every field one-by-one to but this always results in an error 
   saying a necessary field is missing. (except for the start & end date 
   fields)
   - Removing all optional fields
   - Creating a search campaign (which works fine)

But whatever I do, I always get the following error:
GoogleAdsException: operation_access_denied_error, This operation is not 
permitted on this campaign
- or -
An error that says a required field is missing.

There is just nothing left I can think of to solve the error above without 
removing fields that are required to make an App campaign. It would be very 
helpful if the error specified which operation was not permitted.

(I am using the V3 objects from the googleads/google-ads-php composer 
package at version 3.1.0)

$customerId = "4708071192";

try {
    /* @var GoogleAdsClient $googleAdsClient */

    // Generate a refreshable OAuth2 credential for authentication.
    $oAuth2Credential = (new 
OAuth2TokenBuilder())->fromFile(GOOGLE_ADS_SETTINGS)->build();

    // Construct a Google Ads client configured from a properties file and 
the
    // OAuth2 credentials above.
    $googleAdsClient = (new GoogleAdsClientBuilder())
        ->fromFile(GOOGLE_ADS_SETTINGS)
        ->withOAuth2Credential($oAuth2Credential)
        ->build();

    // Create the budget
    $budget = new CampaignBudget();
    $budget->setName(new StringValue(['value' => 'Universal App Campaign 
test budget [' . uniqid() . ']']))
        ->setDeliveryMethod(BudgetDeliveryMethod::STANDARD)
        ->setAmountMicros(new Int64Value(['value' => 500000]))
        ->setExplicitlyShared(new BoolValue(['value' => false]));

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

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

    $addedBudget = $response->getResults()[0];
    $budgetResourceName = $addedBudget->getResourceName();

    // Create the bidding strategy
    $strategy = new BiddingStrategy();
    $strategy->setName(new StringValue(['value' => "testingStrategy19"]));
    $targetcpa = new TargetCpa();
    $targetcpa->setTargetCpaMicros(new Int64Value(['value' => 10000]));
    $strategy->setTargetCpa($targetcpa);

    $biddingStrategyOperation = new BiddingStrategyOperation();
    $biddingStrategyOperation->setCreate($strategy);

    // Issues a mutate request.
    $campaignBudgetServiceClient = 
$googleAdsClient->getBiddingStrategyServiceClient();
    $response = $campaignBudgetServiceClient->mutateBiddingStrategies(
        $customerId,
        [$biddingStrategyOperation]
    );
    $addedBudget = $response->getResults()[0];
    $biddingStrategy = $addedBudget->getResourceName();

    // Create the campaign object
    $startDate = new StringValue(['value' => date('Ymd', 
strtotime("2020-4-1"))]);
    $endDate = new StringValue(['value' => date('Ymd', 
strtotime("2020-4-10"))]);

    $campaignObject = new Campaign();
    $campaignObject->setName(new StringValue(['value' => 'Universal App 
Campaign Test [' . uniqid() . ']']))
        ->setAdvertisingChannelType(AdvertisingChannelType::MULTI_CHANNEL)
        ->setStatus(CampaignStatus::PAUSED)
        ->setCampaignBudget(new StringValue(['value' => 
$budgetResourceName]))
        ->setStartDate($startDate)
        ->setEndDate($endDate)
        
->setAdvertisingChannelSubType(AdvertisingChannelSubType::APP_CAMPAIGN)
        ->setBiddingStrategy(new StringValue(['value' => $biddingStrategy]))
        
->setBiddingStrategyType(\Google\Ads\GoogleAds\V3\Enums\BiddingStrategyTypeEnum\BiddingStrategyType::TARGET_CPA);

    $appCampaignSetting = new AppCampaignSetting();
    
$appCampaignSetting->setBiddingStrategyGoalType(AppCampaignBiddingStrategyGoalType::OPTIMIZE_INSTALLS_TARGET_INSTALL_COST);
    $appCampaignSetting->setAppId(new StringValue(['value' => 
"com.nakko.android.nl100"]));
    $appCampaignSetting->setAppStore(AppCampaignAppStore::GOOGLE_APP_STORE);

    $campaignObject->setAppCampaignSetting($appCampaignSetting);

    // Creates a campaign operation.
    $campaignOperation = new CampaignOperation();
    $campaignOperation->setCreate($campaignObject);

    // Define campaign operations to be executed
    $campaignOperations = [];
    $campaignOperations[] = $campaignOperation;

    $campaignServiceClient = $googleAdsClient->getCampaignServiceClient();
    $response = $campaignServiceClient->mutateCampaigns($customerId, 
$campaignOperations, ['partialFailure' => false]);
    $result = [];
    $campaignId = 0;
    foreach ($response->getResults() as $addedCampaign) {
        $campaignId = $addedCampaign->getResourceName();
        $result[] = [
            "resourceName" => $addedCampaign->getResourceName()
        ];
    }

    echo $campaignId;

} catch (GoogleAdsException $googleAdsException) {
    $errors = [];
    foreach ($googleAdsException->getGoogleAdsFailure()->getErrors() as 
$error) {
        $errors[] = [
            "code" => $error->getErrorCode()->getErrorCode(),
            "message" => $error->getMessage()
        ];

    }
    $errorString = "";

    foreach($errors as $error) {
        $errorString = $errorString.implode(", ", $error);
    }

    throw new Exception("GoogleAdsException: ".$errorString);
} catch (ApiException $apiException) {
    throw new Exception("ApiException: ".$apiException->getMessage());
} catch (Exception $exception){
    throw $exception;
}


-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/4ce3e2e0-37e6-4840-964a-c2343a1ef411%40googlegroups.com.

Reply via email to