CREATE_OPERATION_NOT_PERMITTED for Display Smart campaign

94 views
Skip to first unread message

Andrew Hrimov

unread,
Apr 14, 2022, 3:03:16 AM4/14/22
to Google Ads API and AdWords API Forum
Hello everyone, I'm developing application in Django and using client library for GoogleAds (google-ads). I have Manager account A for first email, and Test Manager account B with some Test Client accounts, testing was OK (using Web-app flow, retrieve refresh token and operate with Test Manager account B, using developer token from Manager account A).

Problem appeared, when I tried to access to another Test Manager account C with some customers, I have such error 
errors {
  error_code {
    operation_access_denied_error: CREATE_OPERATION_NOT_PERMITTED
  }
  message: "Unauthorized CREATE operation in invoking a service\'s mutate method."
  trigger {
    string_value: "DISPLAY_SMART_CAMPAIGN"
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "advertising_channel_sub_type"
    }

  }
}


Accessing account B with it customers did not cause that error, I decided that smith wrong with customers on Test Manager account C, because I have added Test Client from account B and it worked. Can you help me with that?
Runnable code
...
budget_resource_name = create_campaign_budget(
client=client, customer_id=customer_id, campaign=campaign
)
campaign_resource_name = create_campaign(
client=client, customer_id=customer_id, campaign=campaign, budget_name=budget_resource_name
)
...

def create_campaign_budget(client, customer_id: str, campaign: Campaign):
"""Adds a campaign budget to the given client account.
Args:
client: an initialized GoogleAdsClient instance.
customer_id: a client customer ID str.
campaign: campaign instance (model)
Returns:
A str of the resource name for the newly created campaign budget.
"""
campaign_budget_operation = client.get_type("CampaignBudgetOperation")
campaign_budget = campaign_budget_operation.create
campaign_budget.name = f'CampaignBudget for Campaign #{campaign.pk}'
campaign_budget.amount_micros = int(campaign.daily_budget * 10_000 * 100)
campaign_budget.delivery_method = (
client.enums.BudgetDeliveryMethodEnum.STANDARD
)
campaign_budget.explicitly_shared = False
campaign_budget_service = client.get_service("CampaignBudgetService")
response = campaign_budget_service.mutate_campaign_budgets(
customer_id=customer_id, operations=[campaign_budget_operation]
)
resource_name = response.results[0].resource_name
campaign.google_budget_id = resource_name.split('/')[-1]
campaign.save()
return resource_name



def create_campaign(client, customer_id: str, campaign: Campaign, budget_name: str):
"""Adds a Display campaign to the given client account using the given budget.
Args:
client: an initialized GoogleAdsClient instance.
customer_id: a client customer ID str.
campaign: campaign instance (model)
budget_name: the resource name str for a campaign budget.
Returns:
A str of the resource name for the newly created campaign.
"""
google_campaign_service = client.get_service("CampaignService")
google_campaign_operation = client.get_type("CampaignOperation")
google_campaign = google_campaign_operation.create
google_campaign.name = f'{campaign.name} #{campaign.pk}' # must be unique so add pk to name
advertising_channel_type_enum = client.enums.AdvertisingChannelTypeEnum
google_campaign.advertising_channel_type = advertising_channel_type_enum.DISPLAY
advertising_channel_sub_type_enum = (
client.enums.AdvertisingChannelSubTypeEnum
)
# Smart Display campaign requires the advertising_channel_sub_type as
# "DISPLAY_SMART_CAMPAIGN".
google_campaign.advertising_channel_sub_type = (
advertising_channel_sub_type_enum.DISPLAY_SMART_CAMPAIGN
)
status_enum = client.enums.CampaignStatusEnum
if config('GOOGLE_STATUS_AD') == 'ENABLED':
google_campaign.status = status_enum.ENABLED
else:
google_campaign.status = status_enum.PAUSED
# Smart Display campaign requires the TargetCpa bidding strategy.
google_campaign.maximize_conversions.target_cpa = False
google_campaign.campaign_budget = budget_name
# Target: Presence for geotargeting
presence_pos_type = client.enums.PositiveGeoTargetTypeEnum.PRESENCE
google_campaign.geo_target_type_setting.positive_geo_target_type = presence_pos_type
# Run dates
date_format = '%Y%m%d'
start_date, end_date = campaign.start_date, campaign.end_date
google_campaign.start_date = start_date.strftime(date_format)
google_campaign.end_date = end_date.strftime(date_format)

google_campaign_response = google_campaign_service.mutate_campaigns(
customer_id=customer_id, operations=[google_campaign_operation]
)
resource_name = google_campaign_response.results[0].resource_name


Interesting that throws error campaign creation, budget creation is OK. Thanks in advance, any help will be appreciated.

Andrew Hrimov

unread,
Apr 14, 2022, 5:27:27 AM4/14/22
to Google Ads API and AdWords API Forum
As I found else, not all my customers from Test Manager B can create campaign too, for example, my manager customer_id 745-648-6668 has 3 client accounts:
757-944-3809, 731-759-4472, 226-977-9954. And campaign creation request fails just with the last one client customer_id. Can you explain, what I'm doing wrong, login_customer_id is passed (my manager account customer_id that has access (from UI panel Tools & settings -> Access & Security -> Managers).
Thanks again!

четверг, 14 апреля 2022 г. в 10:03:16 UTC+3, Andrew Hrimov:

Andrew Hrimov

unread,
Apr 15, 2022, 1:21:58 PM4/15/22
to Google Ads API and AdWords API Forum
Can someone help me and explain, maybe something is wrong with hierarchy or account settings for client accounts? How I can avoid this error (main idea to operate with Manager account and post ads from it client accounts). Also I can attach request_id for proper investigation if it is not obvious.

Thanks in advance!

четверг, 14 апреля 2022 г. в 12:27:27 UTC+3, Andrew Hrimov:

Google Ads API Forum Advisor

unread,
Apr 18, 2022, 10:12:09 AM4/18/22
to andrew...@gmail.com, adwor...@googlegroups.com

Hi Andrew,

Thanks for reaching out to the Google Ads API Forum.

I can see that you’ve encountered a CREATE_OPERATION_NOT_PERMITTED error. This error indicates an unauthorized CREATE operation in invoking a service's mutate method. However, could you provide us with the complete request and response logs with the request-id generated, so our team can investigate further?

For the client library, logging can be enabled by navigating to the Client libraries > Your client library (ex Java) > Logging documentation, which you can access from this link. You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias by referring to this thread.

Regards,

Google Logo
Yasar
Google Ads API Team
 


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