Removing Campaign Criterion in PHP

32 views
Skip to first unread message

Filip Pećanac

unread,
Nov 5, 2021, 5:13:38 AM11/5/21
to AdWords API and Google Ads API Forum
Hi,

I am trying to remove some of the previously set Campaign Criterions, such as language.

I use the following peace of code:

public function removeCampaignCriterion(
$customerId,
$campaignId,
$criterionId
) {

$campaignCriterionResourceName = ResourceNames::forCampaignCriterion($customerId,$campaignId,$criterionId);

$campaignCriterionOperation = new CampaignCriterionOperation();
$campaignCriterionOperation->setRemove($campaignCriterionResourceName);

$campaignCriterionServiceClient = $this->googleAdsClient->getCampaignCriterionServiceClient();
$campaignCriterionServiceClient->mutateCampaignCriteria(
$customerId,
$campaignCriterionOperation
);

Unfortunately this doesn't work and I get the following message:
Fatal error: Uncaught Google\ApiCore\ApiException: { "message": "Request contains an invalid argument.", "code": 3, "status": "INVALID_ARGUMENT", "details": [ { "@type": 0, "data": "type.googleapis.com\/google.ads.googleads.v8.errors.GoogleAdsFailure" }, { "@type": 0, "data": [ { "errorCode": { "mutateError": "RESOURCE_NOT_FOUND" }, "message": "Resource was not found.", "trigger": { "int64Value": "XXXXXXX" }, "location": { "fieldPathElements": [ { "fieldName": "operations", "index": 0 }, { "fieldName": "remove" } in /var/www/html/Direktorijum/google-ads-php/vendor/google/gax/src/ApiException.php on line 139

I have checked and the campaign Id (XXXXXX value) is correct. 

Could you please help me with this?

Thanks in advance,
Filip

Google Ads API Forum Advisor

unread,
Nov 5, 2021, 10:39:26 AM11/5/21
to filip....@oneassessment.com, adwor...@googlegroups.com
Hi Filip,

Could you privately send us a request and response log of API communication that returns this error?  The request and response appears similar to the JSON Mappings in our REST documentation. Our PHP client library has a logger with logging instructions. Setting the logger to 'DEBUG' will get the desired log.

Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey

Regards,
 
Google Logo
Aryeh Baker
Google Ads API Team
 


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