Hi there,

i'm trying to create a set of adgroup criteria for a campaign (ad 
schedules) with the new php v5 library.
But all i get is an error message saying that the field 'campaign' is 
missing.
This is the debug log output:


[2020-10-02 13:41:06] google-ads.WARNING: Request made: Host: 
"googleads.googleapis.com", Method: 
"/google.ads.googleads.v5.services.CampaignCriterionService/MutateCampaignCriteria",
 
CustomerId: 9060438356, RequestId: "IM6lns_YYYaajRQPX6ocGA", IsFault: 1, 
FaultMessage: "["Field 'campaign' is required for 'CREATE' 
operation.","Field 'campaign' is required for 'CREATE' operation.","Field 
'campaign' is required for 'CREATE' operation.","Field 'campaign' is 
required for 'CREATE' operation.","Field 'campaign' is required for 
'CREATE' operation."]"  
[2020-10-02 13:41:06] google-ads.NOTICE: Request
-------
Method Name: 
/google.ads.googleads.v5.services.CampaignCriterionService/MutateCampaignCriteria
Host: googleads.googleapis.com
Headers: {
    "x-goog-api-client": "gl-php\/7.3.18 gapic\/ gax\/1.4.0 grpc\/1.29.1",
    "x-goog-request-params": "customer_id=9060438356",
    "developer-token": "REDACTED",
    "login-customer-id": "3478781078"
}
Request: 
{"customerId":"9060438356","operations":[{"create":{"adSchedule":{"startMinute":"ZERO","endMinute":"ZERO","dayOfWeek":"MONDAY"}}},{"create":{"adSchedule":{"startMinute":"ZERO","endMinute":"ZERO","dayOfWeek":"TUESDAY"}}},{"create":{"adSchedule":{"startMinute":"ZERO","endMinute":"ZERO","dayOfWeek":"WEDNESDAY"}}},{"create":{"adSchedule":{"startMinute":"ZERO","endMinute":"ZERO","dayOfWeek":"THURSDAY"}}},{"create":{"adSchedule":{"startMinute":"ZERO","endMinute":"ZERO","dayOfWeek":"FRIDAY"}}}]}

Response
-------
Headers: {
    "request-id": "IM6lns_YYYaajRQPX6ocGA",
    "date": "Fri, 02 Oct 2020 11:41:05 GMT",
    "alt-svc": "h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; 
ma=2592000,h3-27=\":443\"; ma=2592000,h3-T051=\":443\"; 
ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; 
ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; 
v=\"46,43\""
}

Fault
-------
Status code: 3
Details: Request contains an invalid argument.
Failure: 
{"errors":[{"errorCode":{"requestError":"REQUIRED_FIELD_MISSING"},"message":"Field
 
'campaign' is required for 'CREATE' 
operation.","location":{"fieldPathElements":[{"fieldName":"operations","index":"0"},{"fieldName":"create"},{"fieldName":"campaign"}]}},{"errorCode":{"requestError":"REQUIRED_FIELD_MISSING"},"message":"Field
 
'campaign' is required for 'CREATE' 
operation.","location":{"fieldPathElements":[{"fieldName":"operations","index":"1"},{"fieldName":"create"},{"fieldName":"campaign"}]}},{"errorCode":{"requestError":"REQUIRED_FIELD_MISSING"},"message":"Field
 
'campaign' is required for 'CREATE' 
operation.","location":{"fieldPathElements":[{"fieldName":"operations","index":"2"},{"fieldName":"create"},{"fieldName":"campaign"}]}},{"errorCode":{"requestError":"REQUIRED_FIELD_MISSING"},"message":"Field
 
'campaign' is required for 'CREATE' 
operation.","location":{"fieldPathElements":[{"fieldName":"operations","index":"3"},{"fieldName":"create"},{"fieldName":"campaign"}]}},{"errorCode":{"requestError":"REQUIRED_FIELD_MISSING"},"message":"Field
 
'campaign' is required for 'CREATE' 
operation.","location":{"fieldPathElements":[{"fieldName":"operations","index":"4"},{"fieldName":"create"},{"fieldName":"campaign"}]}}]}
  




I can see that the request seems to be missing the campaign field, but i 
think the campaign has been set for each new campaign criterion.
This is my code:

....
$campaignResourceName = ResourceNames::forCampaign($accountId, $campaignId);
$operations = [];
foreach ($adScheduleInfos as $adScheduleInfo) {
$campaignCriterion = new CampaignCriterion(
[
'ad_schedule' => $adScheduleInfo,
'campaign' => $campaignResourceName
]
);
$operations[] = new CampaignCriterionOperation(['create' => 
$campaignCriterion]);
}

foreach ($operations as $op) {
var_dump($op->getCreate()->getCampaign());
}

$response = 
$googleAdsClient->getCampaignCriterionServiceClient()->mutateCampaignCriteria($accountId,
 
$operations);
....

The var_dump() prints: 
.... CampaignCriterionAdScheduleHelper.php:90:string 
'customers/9060438356/campaigns/9882431196' (length=41)

But when i look at the request/log, campaign is not set for the operations.
I tried to follow this example: 
https://developers.google.com/google-ads/api/docs/samples/add-campaign-targeting-criteria#php
 
for creating new campaign criteria.
What i'm doing wrong?

Thanks,
Frank

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/09748810-9cbc-44bb-b394-be4fd3d7d16dn%40googlegroups.com.

Reply via email to