Cancel Invitation through Google Ads PHP API

67 views
Skip to first unread message

Waz Anz

unread,
Feb 27, 2023, 10:23:59 AM2/27/23
to Google Ads API and AdWords API Forum
Hi,
We used the following code for V11 and it ran perfectly,

<?php

namespace Google\Ads\GoogleAds\Examples\AccountManagement;

require __DIR__ . '/vendor/autoload.php';

use GetOpt\GetOpt;
use Google\Ads\GoogleAds\Examples\Utils\ArgumentNames;
use Google\Ads\GoogleAds\Examples\Utils\ArgumentParser;
use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder;
use Google\Ads\GoogleAds\Lib\V13\GoogleAdsClient;
use Google\Ads\GoogleAds\Lib\V13\GoogleAdsClientBuilder;
use Google\Ads\GoogleAds\Lib\V13\GoogleAdsException;
use Google\Ads\GoogleAds\Util\FieldMasks;
use Google\Ads\GoogleAds\Util\V13\ResourceNames;
use Google\Ads\GoogleAds\V13\Enums\ManagerLinkStatusEnum\ManagerLinkStatus;
use Google\Ads\GoogleAds\V13\Errors\GoogleAdsError;
use Google\Ads\GoogleAds\V13\Resources\CustomerClientLink;
use Google\Ads\GoogleAds\V13\Resources\CustomerManagerLink;
use Google\Ads\GoogleAds\V13\Services\CustomerClientLinkOperation;
use Google\Ads\GoogleAds\V13\Services\CustomerManagerLinkOperation;
use Google\ApiCore\ApiException;

try {
    $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
    $googleAdsClient = (new GoogleAdsClientBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->build();

    $customerClientLink = new CustomerClientLink([
        'client_customer' => ResourceNames::forCustomer($this_customerId),
        'status' => ManagerLinkStatus::UNSPECIFIED
    ]);

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

    $customerClientLinkServiceClient = $googleAdsClient->getCustomerClientLinkServiceClient();
    try {
        $response = $customerClientLinkServiceClient->mutateCustomerClientLink(MANAGER_CUSTOMER_ID, $customerClientLinkOperation);


        $customerClientLinkResourceName = $response->getResult()->getResourceName();
    } catch (GoogleAdsException $e) {
        printf(
            "Request with ID '%s' has failed.%sGoogle Ads failure details:%s",
            $e->getRequestId(),
            PHP_EOL,
            PHP_EOL
        );
        foreach ($e->getGoogleAdsFailure()->getErrors() as $error) {
            /** @var GoogleAdsError $error */
            printf(
                "\t%s: %s%s",
                $error->getErrorCode()->getErrorCode(),
                $error->getMessage(),
                PHP_EOL
            );
        }

    }
} catch (ApiException $e) {
    printf(
        "ApiException was thrown with message '%s'.%s",
        $e->getMessage(),
        PHP_EOL
    );

 
    print_r($e);
}


And now we are in a process of upgrading it to V13 and its throwing the following error, can anyone help?
Google\ApiCore\ApiException Object
(
[status:Google\ApiCore\ApiException:private] => INVALID_ARGUMENT
[metadata:Google\ApiCore\ApiException:private] => Array
(
[0] => Array
(
[@type] => type.googleapis.com/google.ads.googleads.v13.errors.GoogleAdsFailure
[errors] => Array
 (
  [0] => Array
   (
    [errorCode] => Array
     (
      [managerLinkError] => INVALID_STATUS_CHANGE
     )

    [message] => The changed status for mutate link is invalid.
    [location] => Array
     (
      [fieldPathElements] => Array
       (
        [0] => Array
         (
          [fieldName] => operation
         )

       )

     )

   )

 )

[requestId] => zqj75KZrVSirR4Vm3FyNAw
)

)

Thanks

Waz Anz

unread,
Feb 28, 2023, 2:55:22 AM2/28/23
to Google Ads API and AdWords API Forum
Can anybody help me out?

Google Ads API Forum Advisor

unread,
Feb 28, 2023, 6:34:27 AM2/28/23
to itsw...@gmail.com, adwor...@googlegroups.com
Hi Waz,

Thank you for reaching out to the Google Ads API support team. I hope that you are doing well today.

Moving forward to your concern, I can see that you encountered a INVALID_STATUS_CHANGE error. It indicates that the changed status for the mutate link is invalid. For us to further investigate, could you please provide the complete request and response logs with request ID and request header generated on your end? If you haven't enabled the logging yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link.

You can provide it via Reply privately to the author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Kind regards,
Google Logo Google Ads API Team


ref:_00D1U1174p._5004Q2jHAlV:ref
Reply all
Reply to author
Forward
0 new messages