Hi Team,

I have changed my code a bit but the issues I am facing are same.

Below is the code and API logs from the console. 

-------------------------------x-------------------------------------------x------------------

*Error:*
[2024-09-14 15:43:11,554 - DEBUG] Making request: POST 
https://oauth2.googleapis.com/token
[2024-09-14 15:43:11,562 - DEBUG] Starting new HTTPS connection (1): 
oauth2.googleapis.com:443
[2024-09-14 15:43:11,675 - DEBUG] https://oauth2.googleapis.com:443 "POST 
/token HTTP/11" 200 None

Process finished with exit code -1073741819 (0xC0000005)

--------------------------------------------------------------------------x---------------------

*CODE:*
import logging
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.oauth2.credentials import Credentials
from datetime import datetime, timedelta

# logging
logging.basicConfig(level=logging.DEBUG, format='[%(asctime)s - 
%(levelname)s] %(message)s')
logger = logging.getLogger('google.ads.googleads.client')
logger.setLevel(logging.DEBUG) 

def main(client, customer_id, keywords):
try:
campaign_to_forecast = create_campaign_to_forecast(client, keywords)
generate_forecast_metrics(client, customer_id, campaign_to_forecast)
except GoogleAdsException as ex:
logger.error(f"An API error occurred: {ex.message}")

def create_campaign_to_forecast(client, keywords):
googleads_service = client.get_service("GoogleAdsService")
campaign_to_forecast = client.get_type("CampaignToForecast")
campaign_to_forecast.keyword_plan_network = 
client.enums.KeywordPlanNetworkEnum.GOOGLE_SEARCH

forecast_ad_group = client.get_type("ForecastAdGroup")
for keyword_text in keywords:
biddable_keyword = client.get_type("BiddableKeyword")
biddable_keyword.keyword.text = keyword_text
biddable_keyword.keyword.match_type = 
client.enums.KeywordMatchTypeEnum.BROAD
forecast_ad_group.biddable_keywords.append(biddable_keyword)

campaign_to_forecast.ad_groups.append(forecast_ad_group)
return campaign_to_forecast

def generate_forecast_metrics(client, customer_id, campaign_to_forecast):
keyword_plan_idea_service = client.get_service("KeywordPlanIdeaService")
request = client.get_type("GenerateKeywordForecastMetricsRequest")
request.customer_id = customer_id
request.campaign.CopyFrom(campaign_to_forecast)

response = keyword_plan_idea_service.generate_keyword_forecast_metrics(
request=request)
for forecast_metric in response.keyword_forecasts:
logger.info(f"Keyword: {forecast_metric.keyword.text}, Estimated daily 
clicks: {forecast_metric.clicks}, Estimated daily impressions: {
forecast_metric.impressions}")

if __name__ == "__main__":
credentials = Credentials(
token=None,
refresh_token=" ",
client_id=" ",
client_secret=" ",
token_uri='https://oauth2.googleapis.com/token'
)
client = GoogleAdsClient(
credentials=credentials,
developer_token=" ",
login_customer_id=" "
)

customer_id = "6555392807"
keywords = [
"ads on google", "ads google ads", "google ads google ads google ads",
"advertise with google ads", "add google ads", "google adwords cost",
"google adwords advertising cost", "search engine optimization google 
adwords",
"top advertise", "x ad", "advertising search engine", "new campaign",
"account adwords", "call google ads", "call google advertising",
"google ads cost", "google advertising cost", "google ads search",
"google ads search ads", "search for google ads"
]

main(client, customer_id, keywords)

On Friday 13 September 2024 at 12:17:55 UTC+1 Google Ads API Forum Advisor 
wrote:

> Hi,
>
> Upon checking the logs, I don't see these logs belonging to the Google Ads 
> API endpoints (POST https://api.openai.com/v1/chat/completions). I would 
> request you to share the correct API logs (request 
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#request>
>  and response 
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#response>
>  with request-id 
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#request-id>
>  and request header 
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#request_headers>)
>  
> generated at your end. As you are using the Python client library, you can 
> enable the logging by following this guide 
> <https://developers.google.com/google-ads/api/docs/client-libs/python/logging>
>  
> and share the logs. 
>
>   
> This message is in relation to case 
> "ref:!00D1U01174p.!5004Q02vG4m1:ref" (ADR-00267958)
>
> Thanks,
>   
> [image: Google Logo] Google Ads API Team 
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/95af0430-47cf-404a-a41d-9f53357b91a3n%40googlegroups.com.
  • Ge... Frason Francis
    • ... Frason Francis
      • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
        • ... Frason Francis
    • ... Frason Francis

Reply via email to