Why CriterionError.CANNOT_BID_MODIFY_CRITERION_TYPE on Keywords?

75 views
Skip to first unread message

Ken Dan Tinio

unread,
Jun 27, 2018, 7:40:39 AM6/27/18
to AdWords API and Google Ads API Forum
I have this code that bid adjust on a specific keyword:

        $adGroupCriterionService = $adWordsServices->get($session, AdGroupCriterionService::class);

        $operations = [];

        $keyword = new Keyword();
        $keyword->setId($criterionId);
        $keyword->setText('best science magazines');
        $keyword->setMatchType(KeywordMatchType::BROAD);

        $adGroupCriterion = new BiddableAdGroupCriterion();
        $adGroupCriterion->setAdGroupId($adGroupId);
        $adGroupCriterion->setCriterion($keyword);
        $adGroupCriterion->setBidModifier(1.5);

        // Create ad group criterion operation and add it to the list.
        $operation = new AdGroupCriterionOperation();
        $operation->setOperand($adGroupCriterion);
        $operation->setOperator(Operator::ADD);
        $operations[] = $operation;

        // Create the ad group criteria on the server and print out some information
        // for each created ad group criterion.
        // try {
            $result = $adGroupCriterionService->mutate($operations);
        // } catch (\Exception $e) {
        //     return array(
        //       "status"  => "fail",
        //       "message" => 'Caught exception: '.  $e->getMessage()
        //     );
        // }

        $adGroupCriterion = $result->getValue()[0];

        $data = array(
            "message" => "Keyword with ID %d has updated final URL ",
            "id"      => $adGroupCriterion->getCriterion()->getId()
        );

        array_push(self::$keywords, $data);

The error is:

<br />
<b>Fatal error</b>:  Uncaught Google\AdsApi\AdWords\v201806\cm\ApiException: [CriterionError.CANNOT_BID_MODIFY_CRITERION_TYPE @ operations[0].operand.bidModifier] in /Applications/MAMP/htdocs/native_adwords/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php:43
Stack trace:
#0 /Applications/MAMP/htdocs/native_adwords/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php(43): ReflectionClass-&gt;newInstanceArgs(Array)
#1 /Applications/MAMP/htdocs/native_adwords/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(202): Google\AdsApi\Common\Util\Reflection-&gt;createInstance('Google\\AdsApi\\A...', Array)
#2 /Applications/MAMP/htdocs/native_adwords/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(164): Google\AdsApi\Common\AdsSoapClient-&gt;parseApiExceptionFromSoapFault(Object(SoapFault))
#3 /Applications/MAMP/htdocs/native_adwords/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/v201806/cm/AdGroupCriterionService.php(198 in
<b>/Applications/MAMP/htdocs/native_adwords/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php</b> on line
<b>43</b>
<br />

Peter Oliquino (AdWords API Team)

unread,
Jun 27, 2018, 8:53:59 AM6/27/18
to AdWords API and Google Ads API Forum
Hi Ken,

Could you confirm if you are updating the BidModifier of an existing Keyword BiddableAdGroupCriterion? If yes, you no longer have a need to include the Text and MatchType fields and you could replace the operator from an ADD to a SET instead.

Also, so I can further investigate, could you provide the complete SOAP request and response? You may send it to me privately via the Reply privately to author option.

Thanks and regards,
Peter
AdWords API Team

Ken Dan Tinio

unread,
Jun 27, 2018, 9:04:36 AM6/27/18
to AdWords API and Google Ads API Forum
Yes, finally, someone answered, thank you.

Yes this is an existing keyword that I am trying to bid adjust.

Ken Dan Tinio

unread,
Jun 27, 2018, 9:06:13 AM6/27/18
to AdWords API and Google Ads API Forum
here is my final code:

        $adGroupCriterionService = $adWordsServices->get($session, AdGroupCriterionService::class);

        $operations = [];

        $keyword = new Keyword();
        $keyword->setId($criterionId);

        $adGroupCriterion = new BiddableAdGroupCriterion();
        $adGroupCriterion->setAdGroupId($adGroupId);
        $adGroupCriterion->setCriterion($keyword);
        $adGroupCriterion->setBidModifier(1.5);

        // Create ad group criterion operation and add it to the list.
        $operation = new AdGroupCriterionOperation();
        $operation->setOperand($adGroupCriterion);
        $operation->setOperator(Operator::SET);
        $operations[] = $operation;

        $result = $adGroupCriterionService->mutate($operations);

        $adGroupCriterion = $result->getValue()[0];

        $data = array(
            "message" => "Keyword with ID %d has updated final URL ",
            "id"      => $adGroupCriterion->getCriterion()->getId()
        );

        array_push(self::$keywords, $data);

And I am not using SOAP.


On Wednesday, June 27, 2018 at 3:40:39 PM UTC+8, Ken Dan Tinio wrote:

Ken Dan Tinio

unread,
Jun 27, 2018, 9:06:47 AM6/27/18
to AdWords API and Google Ads API Forum
here is my final code:

        $adGroupCriterionService = $adWordsServices->get($session, AdGroupCriterionService::class);

        $operations = [];

        $keyword = new Keyword();
        $keyword->setId($criterionId);

        $adGroupCriterion = new BiddableAdGroupCriterion();
        $adGroupCriterion->setAdGroupId($adGroupId);
        $adGroupCriterion->setCriterion($keyword);
        $adGroupCriterion->setBidModifier(1.5);

        // Create ad group criterion operation and add it to the list.
        $operation = new AdGroupCriterionOperation();
        $operation->setOperand($adGroupCriterion);
        $operation->setOperator(Operator::SET);
        $operations[] = $operation;

        $result = $adGroupCriterionService->mutate($operations);

        $adGroupCriterion = $result->getValue()[0];

        $data = array(
            "message" => "Keyword with ID %d has updated final URL ",
            "id"      => $adGroupCriterion->getCriterion()->getId()
        );

        array_push(self::$keywords, $data);
And I am not using SOAP.

Peter Oliquino (AdWords API Team)

unread,
Jun 27, 2018, 10:40:04 AM6/27/18
to AdWords API and Google Ads API Forum
Hi Ken,

We highly recommend that you enable your SOAP logging on your end as these logs could significantly help us with the investigation of AdWords API related issues.

Going back to your concern, could you instead send to me privately the Criterion ID and your clientCustomerId so I can investigate further?
Reply all
Reply to author
Forward
0 new messages