Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MutateAdGroupCriterionResult does not return CpcBidMicros #1044

Open
chiragvels opened this issue Aug 26, 2024 · 12 comments
Open

MutateAdGroupCriterionResult does not return CpcBidMicros #1044

chiragvels opened this issue Aug 26, 2024 · 12 comments
Labels
bug Something isn't working triage Need triage

Comments

@chiragvels
Copy link

[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 chiragvels added bug Something isn't working triage Need triage labels Aug 26, 2024
@fiboknacky
Copy link
Member

@chiragvels

Could you share your code too please?

@chiragvels
Copy link
Author

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() : '--';
                 }
           }


@fiboknacky
Copy link
Member

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.

@chiragvels
Copy link
Author

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"

@chiragvels
Copy link
Author

chiragvels commented Aug 27, 2024

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,

@fiboknacky
Copy link
Member

Thanks. That's interesting information and should be helpful to my investigation. Allow me some time to check this.

@chiragvels
Copy link
Author

Hi @fiboknacky ,

did you get a chance to check this?

Thanks,

@fiboknacky
Copy link
Member

Sorry, I'm pretty swamped right now and would be able to take a look at this next week.

@chiragvels
Copy link
Author

chiragvels commented Sep 9, 2024

I might also think

it should be ['partial_failure'=>true] ?

So that in my code
['partial_failure' => true, 'response_content_type' => ResponseContentType::MUTABLE_RESOURCE]

Thanks,

@fiboknacky
Copy link
Member

fiboknacky commented Sep 11, 2024

First, for your mentioned code:

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?

@chiragvels
Copy link
Author

chiragvels commented Sep 11, 2024

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

['partialFailure' => false, 'validateOnly' => true]

['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

@fiboknacky
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Need triage
Projects
None yet
Development

No branches or pull requests

3 participants
@chiragvels @fiboknacky and others