Issue on Customer Client Link with REST API

561 views
Skip to first unread message

Kazi Khayruzzaman

unread,
Jun 7, 2022, 8:16:08 AM6/7/22
to Google Ads API and AdWords API Forum
Hi Google Ads team, 
I'm trying to use this documentation 

to create link between a Manager account and a client account. 
I have added the necessary headers, Authorization, login-customer-id, developer-token. But still no solution to this.

Whenever I send this: 

{
  "operation": {
   
  "create": {
  "resourceName": "customers/1650865311/customerClientLinks/1650865311~2738633711",
  "status": "PENDING",
  "clientCustomer": "1650865311",
  "managerLinkId": "2738633711",
  "hidden": false
  },
  },
  "validateOnly": true
}


It gives me this  error: 

  "error": {
    "status": "INVALID_ARGUMENT",
    "message": "Request contains an invalid argument.",
    "code": 400,
    "details": [
      {
        "errors": [
          {
            "errorCode": {
              "requestError": "RESOURCE_NAME_MALFORMED"
            },
            "message": "Resource name '1650865311' is malformed: expected 'customers/{customer_id}'.",
            "location": {
              "fieldPathElements": [
                {
                  "fieldName": "operation"
                },
                {
                  "fieldName": "create"
                },
                {
                  "fieldName": "client_customer"
                }
              ]
            }
          },
          {
            "errorCode": {
              "requestError": "IMMUTABLE_FIELD"
            },
            "message": "Field 'hidden' cannot be modified by 'CREATE' operation.",
            "location": {
              "fieldPathElements": [
                {
                  "fieldName": "operation"
                },
                {
                  "fieldName": "create"
                },
                {
                  "fieldName": "hidden"
                }
              ]
            }
          },
          {
            "errorCode": {
              "newResourceCreationError": "CANNOT_SET_ID_FOR_CREATE"
            },
            "message": "Do not set the id field while creating new resources.",
            "trigger": {
              "stringValue": "customers/1650865311/customerClientLinks/1650865311~2738633711"
            },
            "location": {
              "fieldPathElements": [
                {
                  "fieldName": "operation"
                },
                {
                  "fieldName": "create"
                },
                {
                  "fieldName": "resource_name"
                }
              ]
            }
          }
        ],
        "@type": "type.googleapis.com/google.ads.googleads.v10.errors.GoogleAdsFailure",
        "requestId": "gbIWqnm3MvgcnhTzUZShYw"
      }
    ]
  }
}

 

Can't find out what's the right argument. 
How to do this in right way with REST API ???


Google Ads API Forum Advisor

unread,
Jun 7, 2022, 10:26:49 AM6/7/22
to me...@felicity.digital, adwor...@googlegroups.com
Hi Kazi,  Thank you for reaching out to Google Ads API support. The errors returned are a good starting point to find out how to send a correct request.

For the error "RESOURCE_NAME_MALFORMED" for field Name "client_customer" the specifics of the error returned is "Resource name '1650865311' is malformed: expected 'customers/{customer_id}"for "fieldName": "client_customer" To fix this you can replace the value of "1650865311" for the key "clientCustomer" with  "customers/1650865311".

For the error "CANNOT_SET_ID_FOR_CREATE" for field name "resource_name" the specifics of the error returned is "Do not set the id field while creating new resources." To fix this you can remove the key - value pair of "managerLinkId", it is already implied by the HTTP header which should be "https://googleads.googleapis.com/v10/customers/1650865311/customerClientLinks:mutate".

For the error IMMUTABLE_FIELD for the field name "hidden", the specifics of the error is "Field 'hidden' cannot be modified by 'CREATE' operation.". To fix this error you may take out the key - value pair of "hidden" from the "create" operation and update the "hidden" field in a second "update" operation.

Here are 2 operations that will get you the desired outcome:
  1. {
        "operation": { 
            "create": {
             "status": "PENDING",
      "clientCustomer": "customers/1650865311",
       
    }
            },
         
    }
    
    
    
  2. {
        "operation": { 
    "updateMask": "hidden",
            "update": {
    "resourceName": "customers/1650865311/customerClientLinks/1650865311~1650865311",
    "hidden": true
       
    }
            },
         
    }
    
    
    
    
Feel free to get back to us.

Regards,

Google Logo
Aryeh
Google Ads API Team
 


ref:_00D1U1174p._5004Q2bd2cU:ref

Kazi Khayruzzaman

unread,
Jun 8, 2022, 4:38:33 AM6/8/22
to Google Ads API and AdWords API Forum
Hi, 
Thanks for the reply. It solved the problem but another problem arrived. Now, I'm getting this 

{
  "error": {
    "status": "PERMISSION_DENIED",
    "message": "The caller does not have permission",
    "code": 403,
    "details": [
      {
        "errors": [
          {
            "errorCode": {
              "authorizationError": "USER_PERMISSION_DENIED"
            },
            "message": "User doesn't have permission to access customer. Note: If you're accessing a client customer, the manager's customer id must be set in the 'login-customer-id' header. See https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid"
          }
        ],
        "@type": "type.googleapis.com/google.ads.googleads.v10.errors.GoogleAdsFailure",
        "requestId": "hH5m60oydlq04UL_uoSHUg"
      }
    ]
  }
}

I have a manager account and i have a client who has his google ads account. I'm trying to connect his client account under my manager account so that I can manage his google ads and get report of his campaigns. I have completed the authentication & authorization, added the access token as header along with developer token, and login-customer-id. I found in the docs that, if I wanna connect my manager account with any other client account, I have to use the customers.customerClientLinks method. 
But it's throwing this error. 

So, my question is, Can I connect any external google ads account with my manager account through REST API? How?
And after adding them, Can I see them listed under the sub-account section in google ads manager account?

Can you help please?


Google Ads API Forum Advisor

unread,
Jun 8, 2022, 7:56:50 AM6/8/22
to me...@felicity.digital, adwor...@googlegroups.com
Hi Kazi,

Thank you for the reply.

With regard to your question if it is possible to connect an external Google Ads account, then the procedure in this document but it appears that you are already doing it. With this, since the issue still persists, could you provide the following details below:
  • Customer Id of the accounts that you want to link. 
  • Complete API request and response logs with request ID and request header that generated on your end
  • Email address that you've used in the authentication
For security purposes, you can provide it via the Reply privately to author option. If this option is not available, then send it instead on this email address googleadsapi-support@google.com.

But to give you an overview about the issue that you encountered encountered, the "USER_PERMISSION_DENIED" which means a user doesn't have permission to access a customer and you’re accessing a client customer using 'login-customer-id’ in the request.

To address this, you will need to ensure that the user / email address you used to generate the credentials indeed has access to the account in your request. If the user / email address has access or is associated with the MCC / manager account, you will need to specify the said MCC / manager account ID as the value of the login-customer-id field.

As for the "Can I see them listed under the sub-account section in google ads manager account?", if the API request for linking accounts is successful, then I can confirm that the account will be listed under the sub-account section in Google Ads Manager account.

Best regards,
Google Logo
Jinky
Google Ads API Team
 


ref:_00D1U1174p._5004Q2bd2cU:ref

Kazi Khayruzzaman

unread,
Jun 9, 2022, 3:58:56 AM6/9/22
to Google Ads API and AdWords API Forum
Hello, 
Replied through privately to author option. 
Please help me out. 

On Wednesday, June 8, 2022 at 5:56:50 PM UTC+6 adsapi wrote:
Hi Kazi,

Thank you for the reply.

With regard to your question if it is possible to connect an external Google Ads account, then the procedure in this document but it appears that you are already doing it. With this, since the issue still persists, could you provide the following details below:
  • Customer Id of the accounts that you want to link. 
  • Complete API request and response logs with request ID and request header that generated on your end
  • Email address that you've used in the authentication
For security purposes, you can provide it via the Reply privately to author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Google Ads API Forum Advisor

unread,
Jun 9, 2022, 7:36:02 AM6/9/22
to me...@felicity.digital, adwor...@googlegroups.com
Hi Kazi,

Thank you for providing the requested information. 

Upon checking this, I can see that you already set the correct customer Id in the login-customer-id field so the error should not persist. To further help you address this, the next thing we need to check is if you are using Oauth credential generated the provided email address. In order to check this, you may login to your GCP credential page using the provided email address. Lastly, compare the client Id and client secret of the GCP credential page and your API configuration. If not the same, you may copy the client Id and client secret from the GCP credential page and apply it in the API configuration. If already the same let us know so that we can raise it to the rest of my team.
Message has been deleted
Message has been deleted

Google Ads API Forum Advisor

unread,
Jun 9, 2022, 11:17:35 AM6/9/22
to me...@felicity.digital, adwor...@googlegroups.com
Hi Kazi,

I had to delete your posts in the forum because they contained logs. Please refer to your private email for the answer.

Regards,

Google Logo
Aryeh
Google Ads API Team
 


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