how catch ApiException fatal error RateExceededError

59 views
Skip to first unread message

David Moate

unread,
Nov 23, 2018, 3:37:27 AM11/23/18
to AdWords API and Google Ads API Forum

Hello i have this issue.

        try{

         
// Generate a refreshable OAuth2 credential for authentication.
          $oAuth2Credential
= (new OAuth2TokenBuilder())
             
->fromFile()
             
->build();
         
// Construct an API session configured from a properties file and the OAuth2

         
// credentials above.

          $session
= (new AdWordsSessionBuilder())
             
->fromFile()
             
->withOAuth2Credential($oAuth2Credential)

             
->build();

          $result
= $this->EstimateKeywordTraffic(new AdWordsServices(), $session);
       
}
       
catch (ApiException $apiException) {
            print_r
($apiException);
       
}

below my error:
Fatal error: Uncaught Google\AdsApi\AdWords\v201802\cm\ApiException: [RateExceededError <rateName=RATE_LIMIT, rateKey=null, rateScope=ACCOUNT, retryAfterSeconds=30>] in /home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php:39 Stack trace: #0 /home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php(39): ReflectionClass->newInstanceArgs(Array) #1 /home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(165): Google\AdsApi\Common\Util\Reflection->createInstance('Google\\AdsApi\\A...', Array) #2 /home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(130): Google\AdsApi\Common\AdsSoapClient->parseApiExceptionFromSoapFault(Object(SoapFault)) #3 /home/refleadfem/ in /home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php on line 39

i wrote use Google\AdsApi\AdWords\v201708\cm\ApiException;
but it does not work.
how to catch this execption thank you for helping me.
my goal is to slow down calls as soon as I catch the exception

Peter Oliquino (AdWords API Team)

unread,
Nov 23, 2018, 5:59:45 AM11/23/18
to AdWords API and Google Ads API Forum
Hi David,

The rateScopre=ACCOUNT that you are getting indicates that you're making too many requests at the same time against a single AdWords account. You can avoid this by decreasing the number of calls you make, and if you wish to catch this error or slow down your calls, you can refer to this section of our rate limits guide.

Let me know if this helps.

Thanks,
Peter
AdWords API Team

David Moate

unread,
Nov 23, 2018, 6:10:29 AM11/23/18
to AdWords API and Google Ads API Forum
Hi Peter,
I wish to catch this error but i can't do it.
it does not work.
and as I can't catch this exception, the fatal error crash my application and I can't make sure to slow down the calls.
This is especially my problem why the exception is not caught.
Thanks for your help

Peter Oliquino (AdWords API Team)

unread,
Nov 25, 2018, 11:06:41 PM11/25/18
to AdWords API and Google Ads API Forum
Hi David,

Could you provide more details about your issue of not being able to catch this exception? Could you confirm if you have already implemented a similar method as the one discussed in this link?

If yes, could you send to me your code and SOAP logs so I can further investigate? You may reply to me via the Reply privately to author option.

Thanks and regards,
Peter
AdWords API Team
Reply all
Reply to author
Forward
0 new messages