Generate Error while Retrieve Campaign Data using Google Ad service Client

38 views
Skip to first unread message

Patel Mayank

unread,
Apr 29, 2024, 5:38:58 PM4/29/24
to Google Ads API and AdWords API Forum
Hello ,
I am Getting  below error while getting campaign data .

Error Description 
Google.Ads.GoogleAds.V16.Errors.GoogleAdsException: 'Status(StatusCode="PermissionDenied", Detail="The caller does not have permission", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1714284860.409000000","description":"Error received from peer ipv4:172.217.27.202:443","file":"..\..\..\src\core\lib\surface\call.cc","file_line":953,"grpc_message":"The caller does not have permission","grpc_status":7}")'

Code Snippet

   string developerToken = .."XXXXX";
   string oAuth2clientId = "XXXXX";
   string oAuth2Secret = "XXX";
   string oAuth2RefreshToken = "XXXXX";
   long loginCustomerId = long.Parse("1111111");    -- Tried with Manager Account ID and Customer ID
   GoogleAdsConfig googleAdsConfig = new GoogleAdsConfig()
   {
       DeveloperToken = developerToken,
       LoginCustomerId = loginCustomerId.ToString(),
       OAuth2ClientId = oAuth2clientId,
       OAuth2ClientSecret = oAuth2Secret,
       OAuth2RefreshToken = oAuth2RefreshToken,
   };

   GoogleAdsClient googleAdsClient = new GoogleAdsClient(googleAdsConfig);
 GoogleAdsServiceClient googleAdsService = googleAdsClient.GetService(
   Services.V16.GoogleAdsService);

 string query = "SELECT campaign.idcampaign.name, campaign.status FROM campaign " +
     "ORDER BY campaign.id limit 100";

 List<string> campaigns = new List<string>();
 try
 {
     // Issue a search request.
     googleAdsService.SearchStream("{CUSTOMER ID}", query,
         delegate (SearchGoogleAdsStreamResponse resp)
         {
             foreach (GoogleAdsRow googleAdsRow in resp.Results)
             {
                 // Note: We don't use the default JSON converter, to enable
                 // better JSON rendering of enum values.
                 //campaigns.Add(JsonFormatter.Default.Format(googleAdsRow.Campaign));
             }
         }
     );

     // return Content($"[{string.Join(",\n", campaigns)}]");
 }
 catch (Exception)
 {
     //return Problem(e.Message);
 }

Note: I have same email address for Ad Manager and Customer ID I have checked Access level as well not sure what is missing here can you please help on that.

Thank you
Reply all
Reply to author
Forward
0 new messages