Google Ads API

190 views
Skip to first unread message

Meri Sahakyan

unread,
Jul 14, 2022, 10:11:30 AM7/14/22
to Google Ads API and AdWords API Forum
Hi, I'm trying to create campaign using Google ads api v11 nuget package for .net core
and getting permission denied error.

Here is client creation:
All configs are created from manager account side

var client = new GoogleAdsClient(new Google.Ads.GoogleAds.Config.GoogleAdsConfig
            {
                OAuth2Mode = Google.Ads.Gax.Config.OAuth2Flow.APPLICATION,
                OAuth2ClientId = "clientId",
                OAuth2ClientSecret = "clientSecret",
                OAuth2RefreshToken = "refreshToken",
                DeveloperToken = "devToken",
                LoginCustomerId = "managerCustomerId"
            });

var retVal = campaignService.MutateCampaigns(customerId, operations); 
// where customerId is customer id of the account linked with manager account.

Am I doing anything wrong here?

Google Ads API Forum Advisor

unread,
Jul 14, 2022, 11:50:39 AM7/14/22
to mer...@purlin.com, adwor...@googlegroups.com
Hi Meri,

Thank you for reaching out to the Google Ads API support team.

With regards to your concern, it seems that you've encountered the USER_PERMISSION_DENIED error. The authorized customer does not have access to the operating customer. The common cause of this is when authenticating as a user with access to a manager account but not specifying login-customer-id in the request. To prevent this kind of error, I would suggest specifying the login-customer-id as the manager account ID without hyphens (-). That being said, 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 MCC / manager account's ID without hyphens (-) as the value of the login-customer-id field. If the issue still persists.

To investigate the issue further, could you please provide the complete request and response logs, with the request-id generated on your end along with the email address used to generate the OAuth2 credentials, so that our team will investigate this problem. 

Thanks,
Google Logo
Nirmitabahen Gaurav
Google Ads API Team
 


ref:_00D1U1174p._5004Q2cW4em:ref
Message has been deleted

Meri Sahakyan

unread,
Jul 15, 2022, 4:31:02 AM7/15/22
to Google Ads API and AdWords API Forum
Screenshot_39.pngGot 200 OK status with valid response

Meri Sahakyan

unread,
Jul 15, 2022, 4:45:03 AM7/15/22
to Google Ads API and AdWords API Forum
But I already mentioned, that I'm using login_customer_id as manager account customer id without dashes.  And checked accesses are set to Admin.
Screenshot_40.png

Google Ads API Forum Advisor

unread,
Jul 15, 2022, 7:10:42 AM7/15/22
to mer...@purlin.com, adwor...@googlegroups.com
Hi Meri,

Thank you for the reply.

If you're trying to create campaign using Postman tool using REST endpoints, then I suggest you to refer to this REST example on how you can create campaign using REST endpoints.

Also, Upon checking your provided screenshot, I can see that you are using https://googleads.googleapis.com/v11/googleAdsFields/ad_group request URI, which is not the correct one. With this, you may note that the correct format is the "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" and this is for the POST method and not to the GET method. Kindly note that the GET methods have been deprecated in V10 and V11 versions.

That being said, you may check this REST documentation example on how you can pull data from reports. You may also check this reporting example to use the Google Ads Query Language in the GoogleAdsService.SearchStream or Search interface.

Best regards,
Google Logo
Heidi
Google Ads API Team
 


ref:_00D1U1174p._5004Q2cW4em:ref

Meri Sahakyan

unread,
Jul 15, 2022, 8:33:49 AM7/15/22
to Google Ads API and AdWords API Forum
Nothing changed
Screenshot_41.png

Meri Sahakyan

unread,
Jul 15, 2022, 8:55:32 AM7/15/22
to Google Ads API and AdWords API Forum
Actually I'm using .net library, not the postman. But even with the postman I'm not able to have successfull response

Google Ads API Forum Advisor

unread,
Jul 15, 2022, 9:10:02 AM7/15/22
to mer...@purlin.com, adwor...@googlegroups.com
Hi Meri,

Could you send us a 'DEBUG' log level request and response log of raw API communications when using List Accessible Accounts and a sample of your other API communications?

The request and response appears similar to the JSON Mappings in our REST documentation with additional headers and information such as request Id. Here are logging instructions for our .NET Ads API Client Library.

If you are using our REST interface then the full multi line curl command line is a request log and adding curl command line option '-i' will also generate a response log.

You may send the requested information via "Reply to author" or via googleadsa...@google.com with a link to this forum post added to the new thread.

Regards,

Google Logo
Aryeh
Google Ads API Team
 


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