Error occurred during parsing: Fail to push the limit

444 views
Skip to first unread message

Sebastian Offers

unread,
Apr 8, 2021, 8:01:33 AM4/8/21
to AdWords API and Google Ads API Forum
Hello maybe anyone has an idea whats wrong.

I got the Error: Error occurred during parsing: Fail to push the limit

This error is since i updated from v2 to v6. 

My System
  • "php": ">=7.3",
  • "google/gax": "^1.7.0",
  • "grpc/grpc": "^1.36.0",
  • "google/protobuf": "^3.15.0",
  • "monolog/monolog": "^2.0"
The only information that i found is which function give probably the error.


The Error comes if i try in the code link the Manager account with the client.

The function looks like following:

 class LinkManagerToClient {

    const MANAGER_CUSTOMER_ID = MANAGER_CUSTOMER_ID;
    const CUSTOMER_ID = CUSTOMER_ID;
    const PAGE_SIZE = 50;

    public static function main() {

      $options = (new ArgumentParser())->parseCommandArguments([
        ArgumentNames::MANAGER_CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
        ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT
      ]);

      try {
        self::runExample(
          $options[ArgumentNames::MANAGER_CUSTOMER_ID] ?: self::MANAGER_CUSTOMER_ID,
          $options[ArgumentNames::CUSTOMER_ID] ?: self::CUSTOMER_ID
        );
      } catch (GoogleAdsException $googleAdsException) {
        printf(
          "Request with ID '%s' has failed.%sGoogle Ads failure details:%s",
          $googleAdsException->getRequestId(),
          PHP_EOL,
          PHP_EOL
        );
        foreach ($googleAdsException->getGoogleAdsFailure()->getErrors() as $error) {
          printf(
            "\t%s: %s%s",
            $error->getErrorCode()->getErrorCode(),
            $error->getMessage(),
            PHP_EOL
          );
        }
      } catch (ApiException $apiException) {
        printf(
          "ApiException was thrown with message '%s'.%s",
          $apiException->getMessage(),
          PHP_EOL
        );
      }

    }

    public static function runExample(int $managerCustomerId, int $clientCustomerId) {

      $customerClientLinkResourceName = self::createInvitation($managerCustomerId, $clientCustomerId);

      $managerLinkResourceName = self::getManagerLinkResourceName($managerCustomerId, $clientCustomerId, $customerClientLinkResourceName);

    }

    public static function createInvitation(int $managerCustomerId, int $clientCustomerId) {

      $googleAdsClient = self::createGoogleAdsClient($managerCustomerId);

      $customerClientLink = new CustomerClientLink([
        'client_customer' => new StringValue(['value' => ResourceNames::forCustomer($clientCustomerId)]),
        'status' => ManagerLinkStatus::PENDING
      ]);

      $customerClientLinkOperation = new CustomerClientLinkOperation();
      $customerClientLinkOperation->setCreate($customerClientLink);

      $customerClientLinkServiceClient = $googleAdsClient->getCustomerClientLinkServiceClient();
      $response = $customerClientLinkServiceClient->mutateCustomerClientLink($managerCustomerId, $customerClientLinkOperation);

      $customerClientLinkResourceName = $response->getResult()->getResourceName();

      return $customerClientLinkResourceName;

    }

    public static function getManagerLinkResourceName(int $managerCustomerId, int $clientCustomerId, string $customerClientLinkResourceName) {

      $googleAdsClient = self::createGoogleAdsClient($managerCustomerId);

      $query = "SELECT customer_client_link.manager_link_id FROM customer_client_link WHERE customer_client_link.resource_name = '$customerClientLinkResourceName'";

      $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
      $response = $googleAdsServiceClient->search(
        $managerCustomerId,
        $query,
        ['pageSize' => self::PAGE_SIZE]
      );

      $managerLinkId = $response->getIterator()->current()
      ->getCustomerClientLink()
      ->getManagerLinkIdUnwrapped();
      $managerLinkResourceName = ResourceNames::forCustomerManagerLink($clientCustomerId, $managerCustomerId, $managerLinkId);

      return $managerLinkResourceName;

    }

    private static function createGoogleAdsClient(int $loginCustomerId) {

      try {

        $oAuth2Credential = (new OAuth2TokenBuilder())
        ->fromFile()
        ->build();

      } catch (Exception $e) {

        echo '3 Caught exception: ',  $e->getMessage(), "\n";

      }

      try {

        return (new GoogleAdsClientBuilder())
        ->fromFile()
        ->withOAuth2Credential($oAuth2Credential)
        ->withLoginCustomerId($loginCustomerId)
        ->build();

      } catch (Exception $e) {

        echo '4 Caught exception: ',  $e->getMessage(), "\n";
        // header("Location: $global_domain/?g_ads=error&g_ads_accountId=1");
        exit;

      }

    }

  }

Thanks a lot for help or any idea

Google Ads API Forum Advisor Prod

unread,
Apr 8, 2021, 3:15:05 PM4/8/21
to sebastia...@gmail.com, adwor...@googlegroups.com
Hello,

Thanks for reaching out. It appears you are using the PHP client library, specifically the LinkManagerToClient.php code example. As your inquiry seems to be with this specific implementation, and not the API itself, I recommend reaching out to the client library owners. You can post your issue on the PHP client library GitHub page here.

Regards,
Matt
Google Ads API Team

Google Logo
Matt
Google Ads API Team
 


ref:_00D1U1174p._5004Q2FWqHB:ref

Sebastian Offers

unread,
Apr 9, 2021, 10:11:59 AM4/9/21
to Google Ads API Forum Advisor Prod, adwor...@googlegroups.com
Thank you for your help! 
Reply all
Reply to author
Forward
0 new messages