How to adjusting bid on an existing ad schedule? its says its already existed.

20 views
Skip to first unread message

Ken Dan Tinio

unread,
Feb 20, 2018, 2:28:39 AM2/20/18
to AdWords API Forum
this is my code for adjust bid in ad schedule.
    // Create a mobile platform. The ID can be found in the documentation.
    $adsched = new AdSchedule();
    $adsched->setDayOfWeek(strtoupper($day_of_the_week));
    $adsched->setStartHour($start_hour);
    $adsched->setStartMinute(strtoupper($string_start_min));
    $adsched->setEndHour($end_hour);
    $adsched->setEndMinute(strtoupper($string_end_min));

    // Create a criterion with modified bid.
    $criterion = new CampaignCriterion();
    $criterion->setCampaignId($campaign_id);
    $criterion->setCriterion($adsched);
    $criterion->setBidModifier($bid_modifier);

    // Create a campaign criterion operation and add it to the operations list.
    $operation = new CampaignCriterionOperation();
    $operation->setOperator(Operator::ADD);
    $operation->setOperand($criterion);
    $operations = [$operation];

and this is my error

 [CampaignCriterionError.CANNOT_ADD_EXISTING_FIELD @ operations[0].operand.bidModifier]

Peter Oliquino

unread,
Feb 20, 2018, 3:20:26 AM2/20/18
to AdWords API Forum
Hi Ken,

Since you are updating an existing AdSchedule campaign criterion, you will need to use the SET operator instead of the ADD :

$operation->setOperator(Operator::SET);

Could you retry your request and see if the issue persists? If yes, you may send to me via the Reply privately to author option the generated SOAP request and response so I can further investigate.

Thanks and regards,
Peter
AdWords API Team

Ken Dan Tinio

unread,
Feb 20, 2018, 3:22:24 AM2/20/18
to AdWords API Forum
Thank you! I already figure it all out. Hehe Hope this helps to other programmers.

Reply all
Reply to author
Forward
0 new messages