Trying to send AdWords invitation [php]

324 views
Skip to first unread message

Mihai Iliescu

unread,
Jun 22, 2017, 7:48:57 AM6/22/17
to AdWords API Forum
Hello,

I'm trying to send invitation using AdWords Api v201702 but I get this error: Fatal error: Uncaught exception 'Google\AdsApi\AdWords\v201702\cm\ApiException' with message '[ManagedCustomerServiceError.UNSUPPORTED @ operations[0]]'

I'm using the code bellow, based on the create account PHP sample:

 // Create link.
$link = new ManagedCustomerLink();
$link->SetLinkStatus = 'PENDING';
$link->SetManagerCustomerId = 'xxxxxxxxxxx';
$link->SetClientCustomerId = 'xxxxxxxxxxx';

$linkop = new LinkOperation();
$linkop->setOperator(Operator::ADD);
        $linkop->setOperand($link);
 
  
// Create operation.
$operations = [];
$operation = new ManagedCustomerOperation();
$operation->setOperator(Operator::ADD);
    $operation->setOperator($linkop);

$operations[] = $operation;


    $result = $managedCustomerService->mutateLink($operations);


----

$operation dump looks like this:

Array
(
    [0] => Google\AdsApi\AdWords\v201702\mcm\ManagedCustomerOperation Object
        (
            [operand:protected] => Google\AdsApi\AdWords\v201702\mcm\LinkOperation Object
                (
                    [operand:protected] => Google\AdsApi\AdWords\v201702\mcm\ManagedCustomerLink Object
                        (
                            [managerCustomerId:protected] => 
                            [clientCustomerId:protected] => 
                            [linkStatus:protected] => 
                            [pendingDescriptiveName:protected] => 
                            [isHidden:protected] => 
                            [SetLinkStatus] => PENDING
                            [SetManagerCustomerId] => xxxx
                            [SetClientCustomerId] => xxxx
                        )

                    [operator:protected] => ADD
                    [OperationType:protected] => 
                )

            [operator:protected] => ADD
            [OperationType:protected] => 
        )

)


Can anyone help me with this?

Shwetha Vastrad (AdWords API Team)

unread,
Jun 22, 2017, 2:25:22 PM6/22/17
to adwor...@googlegroups.com
Hi, 

You need to provide just the LinkOperation when you use the ManagedCustomerService.mutateLink() method as shown here. In your case, it looks like the LinkOperation is encapsulated in a ManagedCustomerOperation. Could you try using the below code snippet? 

    // Create link.
    $link
= new ManagedCustomerLink();
    $link
->SetLinkStatus = 'PENDING';
    $link
->SetManagerCustomerId = 'xxxxxxxxxxx';
    $link
->SetClientCustomerId = 'xxxxxxxxxxx';

    $linkop
= new LinkOperation();
    $linkop
->setOperator(Operator::ADD);
    $linkop
->setOperand($link);


    $operations
[] = $linkop;
    $result
= $managedCustomerService->mutateLink($operations);

Regards,
Shwetha, AdWords API Team.
Message has been deleted

Mihai Iliescu

unread,
Jun 23, 2017, 3:34:10 AM6/23/17
to AdWords API Forum
This code returned  [OperatorError.OPERATOR_NOT_SUPPORTED @ operations[0], RequiredError.REQUIRED @ operations[0].operand, RequiredError.REQUIRED @ operations[0].operator] because operation is undefined. So I adjusted the code as bellow, only to have the same error again: [ManagedCustomerServiceError.UNSUPPORTED @ operations[0]]'

    // Create link.
    $link = new ManagedCustomerLink();
    $link->SetClientCustomerId = 'xxx';
    $link->SetLinkStatus = 'PENDING';
    $link->SetManagerCustomerId = 'xxx';

Shwetha Vastrad (AdWords API Team)

unread,
Jun 23, 2017, 10:18:18 AM6/23/17
to AdWords API Forum
Hi Mihai,

I tried using the below code snippet to extend an invitation and it worked. 

        $managedCustomerService = $adWordsServices->get($session, ManagedCustomerService::class);
        $operations
= [];
        $linkOp
= new LinkOperation();
        $link
= new ManagedCustomerLink();
        $link
->setManagerCustomerId(MANAGER_CID);
        $link
->setClientCustomerId(CLIENT_CID);
        $link
->setLinkStatus("PENDING");
        $linkOp
->setOperand($link);
        $linkOp
->setOperator(Operator::ADD);
        $operations
[] = $linkOp;

        $result
= $managedCustomerService->mutateLink($operations);

Please note that you need to set the clientCustomerId in the request header to the ID of your manager account. If this is not successful, please enable logging and send over the SOAP request and response logs so I can take a look. Please use Reply privately to author when responding. 

Best Dev

unread,
Mar 21, 2018, 5:46:31 AM3/21/18
to AdWords API Forum
Hello,

I can send an invitation to the customer account using Manager account.

but at this moment, I am not sure how I can accept pending invitation. I used Oauth2 and can get Access token. 

I am struggling to accept the invitation but I am still getting [ManagedCustomerServiceError.NOT_AUTHORIZED @ operations[0]] error.

Any help would be appreciated.

Could you guide me in the right direction?


Milind Sankeshware (AdWords API Team)

unread,
Mar 21, 2018, 1:05:47 PM3/21/18
to AdWords API Forum
Hi,

The NOT_AUTHORIZED error occurs when the user authenticating the request is not authorized to perform this operation. Only users with Administrative access can accept and reject manager account link requests. Could you check the access level of the email address used to generate the refresh token? If you still encounter the error with an administrative access, please enable logging and provide the SOAP request and response logs along with the email address used to generate the refresh token and I'll take a look. Please use Reply privately to author to share the details. 
You could use ManagedCustomerService.mutateLink() API to accept the pending invitation, please check this guide for more information. You could also refer sample code in this guide

Thanks,
Milind, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages