how to get with api inactive status for this campaigns? [image: Oi01B92.png][image: nLUXD1T.png]
from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException import os def main(): # Get the path to the google-ads.yaml file script_dir = os.path.dirname(os.path.abspath(__file__)) yaml_path = os.path.join(script_dir, "google-ads.yaml") # Load Google Ads client from the specified configuration file client = GoogleAdsClient.load_from_storage(yaml_path) # Retrieve the customer_id from the YAML configuration customer_id = client.login_customer_id # Get the service for querying campaigns google_ads_service = client.get_service("GoogleAdsService") # Campaign ID to search for campaign_id = 21694145989 # Create a query to get the campaign details including specific status fields query = f""" SELECT campaign.id, campaign.name, campaign.status, campaign.primary_status, campaign.primary_status_reasons, campaign.serving_status FROM campaign WHERE campaign.id = {campaign_id} """ try: # Execute the query and retrieve the results response = google_ads_service.search(customer_id=customer_id, query= query) # Initialize a flag to check if any results were found results_found = False # Output campaign details print(f"Campaign Status Details for ID {campaign_id}:") for row in response: results_found = True campaign = row.campaign print(f"Campaign Name: {campaign.name}") print(f"Campaign ID: {campaign.id}") print(f"Campaign Status: {campaign.status.name}") print(f"Campaign Primary Status: {campaign.primary_status}") print(f"Campaign Serving Status: {campaign.serving_status.name}" ) if campaign.primary_status_reasons: print("Campaign Primary Status Reasons:") for reason in campaign.primary_status_reasons: print(f" - {reason}") else: print("Campaign Primary Status Reasons: None") if not results_found: print(f"No campaign found with ID {campaign_id}") except GoogleAdsException as ex: print(f"Google Ads API Error: {ex}") for error in ex.failure.errors: print(f"\tError with message \"{error.message}\".") if error.location: for field_path_element in error .location.field_path_elements: print(f"\t\tOn field: {field_path_element.field_name}") if __name__ == "__main__": main() -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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/469ca324-bca7-47a8-91a9-0305c78d40ben%40googlegroups.com.