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?)