Error creating campaign with and without bid strategy

302 views
Skip to first unread message

Gregory Golberg

unread,
Feb 18, 2021, 11:14:13 PM2/18/21
to AdWords API and Google Ads API Forum
If I don't specify bidding strategy for a campaign, I get an error that it is required:
-------------------------------------------------------------------------
 error_code {
    field_error: REQUIRED
  }
  message: "The required field was not present."
  trigger {
    string_value: ""
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "campaign_bidding_strategy"
    }
  }
}

-------------------------------------------------------------------------

But if I do, like so:
-------------------------------------------------------------------------
      String bidStrategyResName = null;
      try (BiddingStrategyServiceClient bidStrategySvcCli =
          googleClient.createBiddingStrategyServiceClient()) {

        BiddingStrategy bidStrategy =
            BiddingStrategy.newBuilder().setName("bidding_strategy_123")
                .setTargetCpa(TargetCpa.newBuilder().setTargetCpaMicros(10000L).build()).build();
        BiddingStrategyOperation operation =
            BiddingStrategyOperation.newBuilder().setCreate(bidStrategy).build();
        MutateBiddingStrategiesResponse response =
            bidStrategySvcCli.mutateBiddingStrategies(customerId, Arrays.asList(operation));
        MutateBiddingStrategyResult bidStrategyResult = response.getResults(0);
        bidStrategyResName = bidStrategyResult.getResourceName();
      }

      List<CampaignOperation> campaignOps = new ArrayList<>(1);
      Campaign googleCampaign = null;
      try (CampaignServiceClient campaignServiceClient =
          googleClient.createCampaignServiceClient()) {
        googleCampaign = Campaign.newBuilder().setName("campaign_123")
            .setAdvertisingChannelType(AdvertisingChannelType.MULTI_CHANNEL)
            .setAdvertisingChannelSubType(AdvertisingChannelSubType.APP_CAMPAIGN)
            .setStatus(CampaignStatus.PAUSED)
            .setBiddingStrategy(bidStrategyResName)
            .setCampaignBudget(budgetResName)
            .build();

        CampaignOperation campaignOp =
            CampaignOperation.newBuilder().setCreate(googleCampaign).build();
        campaignOps.add(campaignOp);

        MutateCampaignsResponse campaignResponse =
            campaignServiceClient.mutateCampaigns(customerId, campaignOps);

-------------------------------------------------------------------------

I get a different error:
-------------------------------------------------------------------------
 errors {
  error_code {
    operation_access_denied_error: OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE
  }
  message: "This operation is not permitted on this campaign type"
  trigger {
    string_value: ""
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "bidding_strategy"
    }
  }
}

-------------------------------------------------------------------------
I am setting it to TARGET_CPA because it says in the doc for app campaigns  that "Only the TARGET_CPA bidding strategy type is supported". (Though this same doc also says to use UNIVERSAL_APP_CAMPAIGN as subtype but it does not seem to appear in AdvertisingChannelSubType enum  (anymore?)

Gregory Golberg

unread,
Feb 19, 2021, 2:18:27 AM2/19/21
to AdWords API and Google Ads API Forum
I see that in this thread for a similar problem it is recommended to use preparation steps from doc. So I have done that, now the
code looks like

 googleCampaign = Campaign.newBuilder().setName("campaign_123")
            .setAdvertisingChannelType(AdvertisingChannelType.MULTI_CHANNEL)
            .setAdvertisingChannelSubType(AdvertisingChannelSubType.APP_CAMPAIGN)
            .setAppCampaignSetting(AppCampaignSetting.newBuilder()
                .setBiddingStrategyGoalType(
                    AppCampaignBiddingStrategyGoalType.OPTIMIZE_INSTALLS_TARGET_INSTALL_COST)
                .setAppStore(AppCampaignAppStore.GOOGLE_APP_STORE)
                .setAppId(TEST_PLAY_STORE_APP_ID)
                .build())
            .setStatus(CampaignStatus.PAUSED)
  
//            .setBiddingStrategyType(BiddingStrategyType.TARGET_CPA)
//            .setBiddingStrategy(bidStrategyResName)
         
            .setCampaignBudget(budgetResName)
            .build();

But the same problem occurs -- if bidding strategy is commented out, it says "The required field was not present"; if present, the error is  "This operation is not permitted on this campaign type"

Google Ads API Forum Advisor Prod

unread,
Feb 19, 2021, 12:45:03 PM2/19/21
to deb...@gmail.com, adwor...@googlegroups.com
Hi Gregory,

Thanks for reaching out. I'm seeing documentation from both the Google Ads API and the AdWords API in your messages. It appears you are using the AdWords API, so I recommend limiting your research to its documentation. 

I recommend using the code snippets on this page. I can see that your code has the line:

  .setAdvertisingChannelSubType(AdvertisingChannelSubType.APP_CAMPAIGN)

This method should take the value, AdvertisingChannelSubType.UNIVERSAL_APP_CAMPAIGN, according to the documentation. 

Regards,
Matt
Google Ads API Team

Google Logo
Matt
Google Ads API Team
 


ref:_00D1U1174p._5004Q2CSpVW:ref

Gregory Golberg

unread,
Feb 19, 2021, 1:06:53 PM2/19/21
to AdWords API and Google Ads API Forum
Thanks for reaching out. I'm seeing documentation from both the Google Ads API and the AdWords API in your messages. It appears you are using the AdWords API, so I recommend limiting your research to its documentation.

I'm actually using Ads API (com.google.api-ads:google-ads:10.1.0); sorry for confusion. I'd prefer to use that as that is the newer iteration, right?

 
I recommend using the code snippets on this page. I can see that your code has the line:

.setAdvertisingChannelSubType(AdvertisingChannelSubType.APP_CAMPAIGN)

This method should take the value, AdvertisingChannelSubType.UNIVERSAL_APP_CAMPAIGN, according to the documentation.

Well yes, according to doc it should, but AdvertisingChannelSubType enum, as I pointed out, does not have the UNIVERSAL_APP_CAMPAIGN value. So looks like in the Ads API the right thing to use is APP_CAMPAIGN.

-g


Gregory Golberg

unread,
Feb 21, 2021, 2:17:11 PM2/21/21
to AdWords API and Google Ads API Forum
Any thoughts?

On Friday, February 19, 2021 at 9:45:03 AM UTC-8 adsapiforumadvisor wrote:

Google Ads API Forum Advisor Prod

unread,
Feb 22, 2021, 1:52:25 PM2/22/21
to deb...@gmail.com, adwor...@googlegroups.com
Hi Gregory,

Thanks for clarifying which API is being used. The documentation in your first post specifying that target CPA is the only accepted bidding strategy only applies to AdWords API. 

Can you please provide us with the complete request and response logs associated with the call giving the OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE error?

Thanks,
Message has been deleted

Google Ads API Forum Advisor Prod

unread,
Feb 23, 2021, 12:31:51 AM2/23/21
to deb...@gmail.com, adwor...@googlegroups.com
Hi Gregory,

Thank you for sharing the logs. However, I had to delete your most recent response since it contained the complete logs of your transaction. Moving forward, you may send these details instead via the Reply privately to author option, if required in future interactions.

As for the issue, I understand that you are creating an app campaign and following this guide. Please allow me now to reach out to the rest of our team so we can discuss and investigate the error. We'll reach back to you once we have our findings.

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


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