Error "You are not allowed to make changes to budgets" when creating AccountBudgetProposal with Google Ads API

60 views
Skip to first unread message

Antony Kiên

unread,
Jun 6, 2024, 11:49:48 AM6/6/24
to Google Ads API and AdWords API Forum

  I'm trying to create an AccountBudgetProposal using the Google Ads API (v14), but I keep encountering the following error:

Request with ID "xxxx" failed with status "INVALID_ARGUMENT" and includes the following errors: Error with message "You are not allowed to make changes to budgets." On field: operation  

Steps I've taken:

  1. Verified Permissions:

    • My account has "Standard" access level, which I believe should be sufficient.
    • Confirmed that I have appropriate permissions to make changes to budgets.
  2. Checked Billing Setup Status:

    • Verified that the billing_setup_id is active and correctly formatted.
    • Used the following code to check the status of the billing setup:
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException

def get_billing_setup_status(client, customer_id, billing_setup_id):
    ga_service = client.get_service("GoogleAdsService")

    query = f"""
        SELECT
            billing_setup.id,
            billing_setup.status
        FROM billing_setup
        WHERE billing_setup.resource_name = 'customers/{customer_id}/billingSetups/{billing_setup_id}'
    """

    try:
        response = ga_service.search(customer_id=customer_id, query=query)
        for row in response:
            billing_setup = row.billing_setup
            status = billing_setup.status
            status_name = client.enums.BillingSetupStatusEnum.BillingSetupStatus(status).name
            print(f"Billing setup ID: {billing_setup.id}, Status: {status_name}")
            return status_name
    except GoogleAdsException as ex:
        print(f'Request with ID "{ex.request_id}" failed with status "{ex.error.code().name}" and includes the following errors:')
        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}')
        return None

if __name__ == "__main__":
    google_ads_client = GoogleAdsClient.load_from_storage('path_to_google_ads.yaml', version='v14')
    customer_id = 'your_customer_id'  # Replace with your customer ID
    billing_setup_id = 'your_billing_setup_id'  # Replace with your billing setup ID

    billing_setup_status = get_billing_setup_status(google_ads_client, customer_id, billing_setup_id)
    if billing_setup_status == "ACTIVE":
        print(f"Billing setup {billing_setup_id} is active.")
    else:
        print(f"Billing setup {billing_setup_id} is not active or not found.")
Creating Account Budget Proposal:
  • Attempted to create the AccountBudgetProposal using the following code:

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

def create_account_budget_proposal(client, customer_id, billing_setup_id):
    account_budget_proposal_service = client.get_service("AccountBudgetProposalService")

    account_budget_proposal_operation = client.get_type("AccountBudgetProposalOperation")
    proposal = account_budget_proposal_operation.create

    proposal.proposal_type = client.enums.AccountBudgetProposalTypeEnum.CREATE
    proposal.billing_setup = f'customers/{customer_id}/billingSetups/{billing_setup_id}'
    proposal.proposed_name = "Account Budget Proposal (example)"
    proposal.proposed_start_time_type = client.enums.TimeTypeEnum.NOW
    proposal.proposed_end_time_type = client.enums.TimeTypeEnum.FOREVER
    proposal.proposed_spending_limit_micros = 100000000  # Example amount: $100,000.00

    try:
        account_budget_proposal_response = account_budget_proposal_service.mutate_account_budget_proposals(
            customer_id=customer_id,
            operations=[account_budget_proposal_operation],
        )
        print(f"Created account budget proposal '{account_budget_proposal_response.results[0].resource_name}'.")
    except GoogleAdsException as ex:
        print(f'Request with ID "{ex.request_id}" failed with status "{ex.error.code().name}" and includes the following errors:')
        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}')
        sys.exit(1)

if __name__ == "__main__":
    google_ads_client = GoogleAdsClient.load_from_storage('path_to_google_ads.yaml', version='v14')
    customer_id = 'your_customer_id'  # Replace with your customer ID
    billing_setup_id = 'your_billing_setup_id'  # Replace with your billing setup ID

    billing_setup_status = get_billing_setup_status(google_ads_client, customer_id, billing_setup_id)
    if billing_setup_status == "ACTIVE":
        create_account_budget_proposal(google_ads_client, customer_id, billing_setup_id)
    else:
        print("The billing setup ID is not active or not found. Please check the billing setup ID and try again.")

Questions:

  1. Are there any specific permissions required beyond "Standard" to make changes to budgets?
  2. Is there any additional configuration needed for billing_setup_id to be accepted?
  3. Could there be any other reason why I am encountering this error despite having the correct permissions and an active billing setup?

Any help or insights would be greatly appreciated. Thank you!

Google Ads API Forum Advisor

unread,
Jun 6, 2024, 3:48:31 PM6/6/24
to kiez...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

Please find the below responses for your queries:

1) Are there any specific permissions required beyond "Standard" to make changes to budgets?
  • I would like to inform you that the "Standard" access should allow budget modifications. If you're working within a Manager account structure, ensure you have the necessary permissions at the manager level to manage budgets for child accounts.
2) Is there any additional configuration needed for billing_setup_id to be accepted?
  • Your code snippet for checking the billing setup status seems correct.
3) Could there be any other reason why I am encountering this error despite having the correct permissions and an active billing setup?
  • Please ensure you're creating an AccountBudgetProposal, not a campaign budget proposal.
The error message "You are not allowed to make changes to budgets" indicates a permission issue that's preventing you from creating an AccountBudgetProposal using the Google Ads API. I would suggest you refer to the document Account Budget to get more information.

Also, I could see that you are still using the 'v14' of the Google Ads API which is already deprecated. I would recommend migrating to the latest version v17, please follow this guide to upgrade to the latest version. Please note that we are unable to reproduce any response with the request that you have provided.

If you are still facing the issues, share the complete API logs (request, response, request-id and request header) generated on your device with us. 

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java, .Net, PHP, Python, Ruby or Perl to enable logging at your end. You can enable logging via the curl command by using the -i flag for REST interface requests.

You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02tJEl1:ref" (ADR-00238754)

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages