Hi,

I am trying to create an app campaign with the new API. I tried with both 
Java and Python, getting the same error message as below. The error message 
in Java is MUTATE_ACTION_NOT_PERMITTED_FOR_CLIENT, I don't understand what 
exactly I am trying to "mutate"? Basically I think the mutation is creating 
campaign and budget. I used the sample code of add_campaigns.py which came 
with the client lib as reference.

Attached is the python script, pls take a look and help! Thx!!

Request made: ClientCustomerId: 9189232388, Host: 
googleads.googleapis.com:443, Method: 
/google.ads.googleads.v2.services.CampaignService/MutateCampaigns, 
RequestId: mGoLwJYa1kppmiEsJYGjPg, IsFault: True, FaultMessage: A mutate 
action is not allowed on this campaign, from this client.

Request with ID "mGoLwJYa1kppmiEsJYGjPg" failed with status 
"INVALID_ARGUMENT" and includes the following errors:

Error with message "A mutate action is not allowed on this campaign, from 
this client.".

On field: operations

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 
"AdWords API and Google Ads 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/bd5f304d-a96d-41ad-8f68-a629e5dd43f0%40googlegroups.com.
#!/usr/bin/env python
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This example illustrates how to add a campaign.

To get campaigns, run get_campaigns.py.
"""

from __future__ import absolute_import

import argparse
import datetime
import six
import sys
import uuid

import google.ads.google_ads.client


_DATE_FORMAT = '%Y%m%d'


def main(client, customer_id):
    campaign_budget_service = client.get_service('CampaignBudgetService',
                                                 version='v2')
    campaign_service = client.get_service('CampaignService', version='v2')

    # Create a budget, which can be shared by multiple campaigns.
    campaign_budget_operation = client.get_type('CampaignBudgetOperation',
                                                version='v2')
    campaign_budget = campaign_budget_operation.create
    campaign_budget.name.value = 'Interplanetary Budget 1 %s' % uuid.uuid4()
    campaign_budget.delivery_method = client.get_type(
        'BudgetDeliveryMethodEnum').STANDARD
    campaign_budget.amount_micros.value = 500000
    #campaign_budget.explicitly_shared = False

    # Add budget.
    try:
        campaign_budget_response = (
            campaign_budget_service.mutate_campaign_budgets(
                customer_id, [campaign_budget_operation]))
    except google.ads.google_ads.errors.GoogleAdsException as ex:
        print('Request with ID "%s" failed with status "%s" and includes the '
              'following errors:' % (ex.request_id, ex.error.code().name))
        for error in ex.failure.errors:
            print('\tError with message "%s".' % error.message)
            if error.location:
                for field_path_element in error.location.field_path_elements:
                    print('\t\tOn field: %s' % field_path_element.field_name)
        sys.exit(1)

    # Create campaign.
    campaign_operation = client.get_type('CampaignOperation', version='v2')
    campaign = campaign_operation.create
    campaign.name.value = 'Python test campaign %s' % uuid.uuid4()
    campaign.advertising_channel_type = client.get_type(
        'AdvertisingChannelTypeEnum').MULTI_CHANNEL

    # Set campaign sub type.
    campaign.advertising_channel_sub_type = client.get_type(
        'AdvertisingChannelSubTypeEnum').APP_CAMPAIGN


    # Recommendation: Set the campaign to PAUSED when creating it to prevent
    # the ads from immediately serving. Set to ENABLED once you've added
    # targeting and the ads are ready to serve.
    campaign.status = client.get_type('CampaignStatusEnum', version='v2').PAUSED

    # Set the bidding strategy and budget.
    campaign.manual_cpc.enhanced_cpc_enabled.value = True
    campaign.campaign_budget.value = (
        campaign_budget_response.results[0].resource_name)

    # Set the campaign network options.
    campaign.network_settings.target_google_search.value = True
    campaign.network_settings.target_search_network.value = True
    campaign.network_settings.target_content_network.value = False
    campaign.network_settings.target_partner_search_network.value = False

    # Optional: Set the start date.
    start_time = datetime.date.today() + datetime.timedelta(days=1)
    campaign.start_date.value = datetime.date.strftime(start_time,
                                                       _DATE_FORMAT)

    # Optional: Set the end date.
    end_time = start_time + datetime.timedelta(weeks=4)
    campaign.end_date.value = datetime.date.strftime(end_time, _DATE_FORMAT)

    # App campaign setting
    campaign.app_campaign_setting.app_id.value = '938003185'
    campaign.app_campaign_setting.app_store = client.get_type('AppCampaignAppStoreEnum').APPLE_APP_STORE
    campaign.app_campaign_setting.bidding_strategy_goal_type = client.get_type('AppCampaignBiddingStrategyGoalTypeEnum').OPTIMIZE_INSTALLS_TARGET_INSTALL_COST

    # Add the campaign.
    try:
        campaign_response = campaign_service.mutate_campaigns(
            customer_id, [campaign_operation])
    except google.ads.google_ads.errors.GoogleAdsException as ex:
        print('Request with ID "%s" failed with status "%s" and includes the '
              'following errors:' % (ex.request_id, ex.error.code().name))
        for error in ex.failure.errors:
            print('\tError with message "%s".' % error.message)
            if error.location:
                for field_path_element in error.location.field_path_elements:
                    print('\t\tOn field: %s' % field_path_element.field_name)
        sys.exit(1)

    print('Created campaign %s.' % campaign_response.results[0].resource_name)


if __name__ == '__main__':
    # GoogleAdsClient will read the google-ads.yaml configuration file in the
    # home directory if none is specified.
    google_ads_client = (google.ads.google_ads.client.GoogleAdsClient
                         .load_from_storage())

    parser = argparse.ArgumentParser(
        description='Adds a campaign for specified customer.')
    # The following argument(s) should be provided to run the example.
    parser.add_argument('-c', '--customer_id', type=six.text_type,
                        required=True, help='The Google Ads customer ID.')
    args = parser.parse_args()

    main(google_ads_client, args.customer_id)
  • create app camp... 'Naomi Shao' via AdWords API and Google Ads API Forum

Reply via email to