Hello - I am using Python script to pull Campaign Information . I generated the refresh token via Google Oauth2 Playground and use that in the script to generate access token when the script is run. Below is the code , I use to hit the api .
import requests def fetch_campaigns(customer_id, access_token, developer_token): url = f"https://googleads.googleapis.com/v18/customers/{customer_id}/googleAds:search" headers = { "Authorization": f"Bearer {access_token}", "developer-token": developer_token, "Content-Type": "application/json" } query = { "query": """ SELECT customer.id, customer.manager, customer.resource_name, customer.status, customer.test_account, campaign.name, campaign.id FROM campaign """ } try: response = requests.post(url, json=query, headers=headers) print("Status Code:", response.status_code) print("Headers:", response.headers) print("Response Body:", response.json()) # Raise an error for bad status codes response.raise_for_status() # Return the JSON response return response.json() except requests.exceptions.RequestException as e: print("Error making request:", e) return None # Example usage customer_id = "INSERT_CUSTOMER_ID_HERE" access_token = "INSERT_ACCESS_TOKEN_HERE" developer_token = "INSERT_DEVELOPER_TOKEN_HERE" result = fetch_campaigns(customer_id, access_token, developer_token) if result: print("Campaigns:", result). I get the status code '200' . But the response is missing the "results" field. We have a master customer account and under we have multiple accounts for each department. So do I need to provide the account id as well to get the results ? If yes , the how ? I am not seeing any resources mentioning that step. Kindly help me out on this. Thanks, Arun -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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 visit https://groups.google.com/d/msgid/adwords-api/6591e4f8-c9b2-426c-9f95-d9e3fb092d5an%40googlegroups.com.