Problem getting get_campaigns.py example

313 views
Skip to first unread message

Kazeazul

unread,
Sep 28, 2022, 7:14:36 PM9/28/22
to Google Ads API and AdWords API Forum
Hello everyone I'm having some issues I'm trying to connect to google ads api using python I configure the yaml file and seems nothing weird when I create the client, then I'm trying to create the report using this script

import argparse
import sys
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException

def main(client, customer_id):
    ga_service = client.get_service("GoogleAdsService")
    query = """
        SELECT
          campaign.id,
          campaign.name,
          ad_group.id,
          ad_group.name,
          ad_group_criterion.criterion_id,
          ad_group_criterion.keyword.text,
          ad_group_criterion.keyword.match_type,
          metrics.impressions,
          metrics.clicks,
          metrics.cost_micros
        FROM keyword_view WHERE segments.date DURING LAST_7_DAYS
        AND campaign.advertising_channel_type = 'SEARCH'
        AND ad_group.status = 'ENABLED'
        AND ad_group_criterion.status IN ('ENABLED', 'PAUSED')
        ORDER BY metrics.impressions DESC
        LIMIT 50"""

    # Issues a search request using streaming.
    search_request = client.get_type("SearchGoogleAdsStreamRequest")
    search_request.customer_id = customer_id
    search_request.query = query
    stream = ga_service.search_stream(search_request)
    for batch in stream:
        for row in batch.results:
            campaign = row.campaign
            ad_group = row.ad_group
            criterion = row.ad_group_criterion
            metrics = row.metrics
            print(
                f'Keyword text "{criterion.keyword.text}" with '
                f'match type "{criterion.keyword.match_type.name}" '
                f"and ID {criterion.criterion_id} in "
                f'ad group "{ad_group.name}" '
                f'with ID "{ad_group.id}" '
                f'in campaign "{campaign.name}" '
                f"with ID {campaign.id} "
                f"had {metrics.impressions} impression(s), "
                f"{metrics.clicks} click(s), and "
                f"{metrics.cost_micros} cost (in micros) during "
                "the last 7 days.")

main(google_ads_client, " 6741424893")

I'm getting the following errors

Request made: ClientCustomerId: 2489367414, Host: googleads.googleapis.com, Method: /google.ads.googleads.v8.services.GoogleAdsService/SearchStream, RequestId: None, IsFault: True, FaultMessage: Operation is not implemented, or supported, or enabled.

MethodNotImplemented: 501 Operation is not implemented, or supported, or enabled.

Please if someone can help me

Google Ads API Forum Advisor

unread,
Sep 29, 2022, 2:17:11 AM9/29/22
to daguil...@gmail.com, adwor...@googlegroups.com
Hi,

This is Carmela from the Google Ads API team. Thank you for reaching out.

Moving forward, I noticed that you are still using the v8 of the Google Ads API which has already been sunsetted last May 11, 2022, according to this blog post. Having said that, I would highly suggest upgrading to the newest version of the Google Ads API as soon as possible to avoid issues on your end.

If the error persists even after using the latest version, then feel free to get back to us and provide the complete request and response logs with request ID and request header for further investigation. You can provide it via Reply privately to author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Regards,
Google Logo
Carmela
Google Ads API Team
 


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