google-ads-php icon indicating copy to clipboard operation
google-ads-php copied to clipboard

Invalid Argument

Open latiefqohar opened this issue 3 years ago • 1 comments

Hello, I did several queries with the same query. the following query i did

SELECT ad_group_ad.ad.final_urls,ad_group_ad.status, metrics.cost_micros FROM ad_group_ad WHERE segments.date >= '2022-07-01' AND segments.date <= '2022-07-31' and ad_group_ad.status = 'ENABLED' ORDER BY metrics.cost_micros

I made several requests with the query listed above. the query is successful and sometimes the query has an error

======================================================================== error displayed

An uncaught Exception was encountered Type: Google\Ads\GoogleAds\Lib\V8\GoogleAdsException

Message: { "message": "Request contains an invalid argument.", "code": 3, "status": "INVALID_ARGUMENT", "details": [ { "@type": "google.ads.googleads.v8.errors.googleadsfailure-bin", "data": "" }, { "@type": "grpc-status-details-bin", "data": "" }, { "@type": "request-id", "data": "AXY5aYwfbxFuO9fsplQS7w" } ] }

Filename: /mnt/data/home/538683.cloudwaysapps.com/zychgrwtef/public_html/cart/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V8/GoogleAdsExceptionTrait.php

Line Number: 75

Backtrace:

File: /mnt/data/home/538683.cloudwaysapps.com/zychgrwtef/public_html/cart/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V8/GoogleAdsExceptionTrait.php Line: 50 Function: createGoogleAdsException

File: /mnt/data/home/538683.cloudwaysapps.com/zychgrwtef/public_html/cart/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V8/ServerStreamingGoogleAdsExceptionMiddleware.php Line: 97 Function: throwGoogleAdsException

File: /mnt/data/home/538683.cloudwaysapps.com/zychgrwtef/public_html/cart/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V8/ServerStreamingGoogleAdsResponseMetadataCallable.php Line: 75 Function: readAll

end code

===================================================================== and this is my code

protected function get_gads_cost_for_test(GoogleAdsClient $googleAdsClient, int $customerId, string $source, $startDate, $endDate) { $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();

    $query = "SELECT ad_group_ad.ad.final_urls,ad_group_ad.status, metrics.cost_micros FROM ad_group_ad WHERE segments.date >= '$startDate' AND segments.date <= '$endDate' and ad_group_ad.status = 'ENABLED' ORDER BY metrics.cost_micros";

    $stream = $googleAdsServiceClient->searchStream($customerId, $query);

    $totalAds = 0;
    foreach ($stream->iterateAllElements() as $googleAdsRow) {

        foreach($googleAdsRow->getAdGroupAd()->getAd()->getFinalUrls() as $finalUrlRow) {
            if (preg_match("/sumber=$source\b/i", $finalUrlRow)){
                $totalAds += $googleAdsRow->getMetrics()->getCostMicros() / 1000000;
            }
        }
    }
    return $totalAds;
}

=============================================================================== end code

can you help me why the API is unstable so sometimes it works and sometimes it error.

latiefqohar avatar Jul 02 '22 11:07 latiefqohar

v8 is already sunset. Could you please upgrade to the latest version and try again?

fiboknacky avatar Jul 03 '22 16:07 fiboknacky

Closing due to inactivity. Feel free to reopen this if you still face the issue.

fiboknacky avatar Aug 29 '22 06:08 fiboknacky