MutateAdGroupCriterionResult does not return CpcBidMicros
[DO NOT INCLUDE ANY PERSONAL OR SENSITIVE DATA - MAKE SURE TO REDACT CONTENT WHEN NECESSARY]
Your client library and Google Ads API versions:
- Client library version:
v23.1.0
- Google Ads API version:
V17
Your environment: PHP 8.1.2-1ubuntu2.18 Linux
Description of the bug: I am not able to get AdGroupCriterion object with option getAdGroupCriterion(); And so that I cannot see CpcBidMicros
Steps to reproduce: I was trying to update response for keywords through mutateAdGroupCriteria.
Expected behavior: Should have return macCPC and AdGroupCriterion Object. Request/Response Logs: object(Google\Ads\GoogleAds\V17\Services\MutateAdGroupCriterionResult)#146 (0) { } Operation 0 succeeded: ad group with resource name 'customers/XXXXX/adGroupCriteria/1148XXX3111~39774910'.
Anything else we should know about your project / environment:
@chiragvels
Could you share your code too please?
Hi @fiboknacky ,
The code :
$response = $adGroupCriterionServiceClient->mutateAdGroupCriteria(
MutateAdGroupCriteriaRequest::build($this->client_id, $adGroupCriterionOperations),
['partialFailure' => true, 'responseContentType' => ResponseContentType::MUTABLE_RESOURCE]
);
if($response->getResults()->count()){
$operationIndex = 0;
foreach ($response->getResults() as $addedAdGroupCriterion) {
printf(
"Operation %d succeeded: ad group with resource name '%s'.%s",
$operationIndex,
$addedAdGroupCriterion->getResourceName(),
PHP_EOL
);
$kwAmount = ($addedAdGroupCriterion->getAdGroupCriterion() != NULL) ? $addedAdGroupCriterion->getAdGroupCriterion()->getCpcBidMicros() : '--';
}
}
Could you share the whole code like how you created the ad group criterion operation? And if you have a request ID, could you also share it here too? Thanks.
Hi @fiboknacky ,
Part of the code:
$adGroupCriterion = new AdGroupCriterion([
'resource_name' => ResourceNames::forAdGroupCriterion(
$this->client_id,
$adGroupId,
$criterionId
),
'cpc_bid_micros' => $max_cpc_in_micros
]);
$adGroupCriterionOperation = new AdGroupCriterionOperation();
$adGroupCriterionOperation->setUpdate($adGroupCriterion);
$adGroupCriterionOperation->setUpdateMask(FieldMasks::allSetFieldsOf($adGroupCriterion));
$adGroupCriterionOperations[] = $adGroupCriterionOperation;
$adGroupCriterionServiceClient = $googleAdsClient->getAdGroupCriterionServiceClient();
$response = $adGroupCriterionServiceClient->mutateAdGroupCriteria(
MutateAdGroupCriteriaRequest::build($this->client_id, $adGroupCriterionOperations),
['partialFailure' => true, 'responseContentType' => ResponseContentType::MUTABLE_RESOURCE]
);
if($response->getResults()->count()){
$operationIndex = 0;
foreach ($response->getResults() as $addedAdGroupCriterion) {
printf(
"Operation %d succeeded: ad group with resource name '%s'.%s",
$operationIndex,
$addedAdGroupCriterion->getResourceName(),
PHP_EOL
);
$kwAmount = ($addedAdGroupCriterion->getAdGroupCriterion() != NULL) ? $addedAdGroupCriterion->getAdGroupCriterion()->getCpcBidMicros() : '--';
}
}
RequestId: "4Kz5u1DT2MXMEZtOR3Q9BQ"
Hi @fiboknacky ,
This is strange.
worked with this code
$response = $adGroupCriterionServiceClient->mutateAdGroupCriteria(
MutateAdGroupCriteriaRequest::build($this->client_id, $adGroupCriterionOperations)
->setPartialFailure(true)
->setResponseContentType(ResponseContentType::MUTABLE_RESOURCE)
);
But not with this code
$response = $adGroupCriterionServiceClient->mutateAdGroupCriteria(
MutateAdGroupCriteriaRequest::build($this->client_id, $adGroupCriterionOperations),
['partialFailure' => true, 'responseContentType' => ResponseContentType::MUTABLE_RESOURCE]
);
"request-id": "DFTKWP1FJufECXQBo-xiHA", Thanks,
Thanks. That's interesting information and should be helpful to my investigation. Allow me some time to check this.
Hi @fiboknacky ,
did you get a chance to check this?
Thanks,
Sorry, I'm pretty swamped right now and would be able to take a look at this next week.
I might also think https://github.com/googleads/google-ads-php/blob/357866960b34125a21ef1c3c7b193ee7d68dfa20/examples/ErrorHandling/HandlePartialFailure.php#L185
it should be ['partial_failure'=>true] ?
So that in my code ['partial_failure' => true, 'response_content_type' => ResponseContentType::MUTABLE_RESOURCE]
Thanks,
First, for your mentioned code: https://github.com/googleads/google-ads-php/blob/357866960b34125a21ef1c3c7b193ee7d68dfa20/examples/ErrorHandling/HandlePartialFailure.php#L185
It should be
MutateAdGroupsRequest::build($customerId, $operations)->setPartialFailure(true)
as explained in this section.
I'll update this example soon.
Therefore, for your code, it should be:
MutateAdGroupCriteriaRequest::build($this->client_id, $adGroupCriterionOperations)
->setPartialFailure(true)
->setResponseContentType(ResponseContentType::MUTABLE_RESOURCE)
Could you please try it?
Hi @fiboknacky ,
Yes, it is working as I mentioned in my earlier comment here
However, the issue arises with options passed as an array like this or https://github.com/googleads/google-ads-php/blob/357866960b34125a21ef1c3c7b193ee7d68dfa20/examples/ErrorHandling/HandleRateExceededError.php#L257
['partialFailure' => true, 'responseContentType' => ResponseContentType::MUTABLE_RESOURCE]
This would fail.
As I checked examples, partial failures are used as 'partialFailure' in examples everywhere, but I believe it should be 'partial_failure'.
Therefore, using:
['partial_failure' => true]
should work?
Thanks
No. That wouldn't work after we migrated to GAPIC v2 as I mentioned above.
HandleRateExceededError.php would need an update too. Sorry that we didn't see this earlier.
Closing as the instructions have been provided.
It's already changed to this style.