Hello,
I'm trying to update a campaign's bidding strategy:

$biddingStrategy = new BiddingStrategy();
$biddingStrategy->setType($type);

if ($type == BiddingStrategyType::TARGET_ROAS)
{
    $targetRoas = new TargetRoas(['target_roas' => $bid]);
    $biddingStrategy->setTargetRoas($targetRoas);
}
else
{
    $money = new Money();
    $bidValue = new Int64Value();
    $bidValue->setValue($bid);
    $money->setAmountMicros($bidValue);
    $targetSpa = new TargetCpa(['target_cpa_micros' => 
$money->getAmountMicros()]);
    $biddingStrategy->setTargetCpa($targetSpa);
}

// Create campaign using an existing ID.
$campaign = new Campaign([
    'resource_name' => ResourceNames::forCampaign($this->account_google_id, 
$campaign_pin_id),
    'bidding_strategy' => $biddingStrategy
]);

$campaignOperation = new CampaignOperation();
$campaignOperation->setUpdate($campaign);
$campaignOperation->setUpdateMask(FieldMasks::allSetFieldsOf($campaign));
$response = $this->campaignServiceClient->mutateCampaigns(
    $this->account_google_id,
    [$campaignOperation]
);
return $response->getResults()[0];


The code below fails with "Expect Google\Protobuf\StringValue." error. 

The reason is in the bidding_strategy assignment:


$campaign = new Campaign([
    'resource_name' => ResourceNames::forCampaign($this->account_google_id, 
$campaign_pin_id),
    'bidding_strategy' => $biddingStrategy
]);


I tried to call $biddingStrategy->serializeToString() or 
$biddingStrategy->serializeToJsonString() but it does not help.

How to assign the bidding strategy?



-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/2a7812a2-a21e-4204-92c0-d25478eec8c5%40googlegroups.com.

Reply via email to