Can't mutate youtube media id with youtubeVideoMediaIdsOps in UAC

70 views
Skip to first unread message

i.ti...@corp.mail.ru

unread,
Feb 22, 2019, 5:56:57 PM2/22/19
to AdWords API and Google Ads API Forum
Hello!

Why I can't change youtubeVideoMediaIds list in my UAC (but this UAC is Video ads only), but for other campaigns in my account I can do this operation

This is my code:

self.settings = {
    'xsi_type': 'UniversalAppCampaignSetting',
    'youtubeVideoMediaIdsOps': self.video_ids,
}

def _update_media_data(self):
    operations = [{
        'operator': 'SET',
        'operand': {
            'id': self.campaign.id,
            'settings': self.settings
        }
    }]
    print(operations)
    return self.campaign_service.mutate(operations)['value'][0]['settings'][1]['youtubeVideoMediaIds']

this code works for other campaigns and I can change youtube media ids but in this UAC can't

this is error:

googleads.errors.GoogleAdsServerFault: [SettingError.YOUTUBE_MEDIA_IDS_REQUIRED_IN_VIDEO_ONLY_UAC @ operations[0].operand.settings[0].youtubeVideoMediaIds; trigger:'[]']

googleadsapi...@google.com

unread,
Feb 25, 2019, 2:42:44 PM2/25/19
to AdWords API and Google Ads API Forum
Hello, 

The AdWords API currently does not support creating new YoutubeVideoMedia, so you need to manually set the campaign's YouTube Video assets through the AdWords UI. If you already have existing youtube media in your account, you will be able to use CampaignService.mutate() to add new settings to the campaign. You will need to do a MediaService.get() to get the specific youtube media Id and then use the UniversalAppSetting to add the new media setting to the campaign. Please find the code snippet below as a reference:

UniversalAppCampaignSetting universalAppSetting = new UniversalAppCampaignSetting(); 
universalAppSetting.setYoutubeVideoMediaIds(new long[] {4390676349L}); 
campaign.setSettings(new Setting[] {universalAppSetting});

CampaignOperation operation = new CampaignOperation();
operation.setOperand(campaign);
operation.setOperator(Operator.SET);

If you're still having an issue, could you please share the API SOAP logs, so I can take a closer look?

Thanks,
Bharani, AdWords API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@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+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/d69ba090-74d8-49bb-8daf-b523a19c789b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

i.ti...@corp.mail.ru

unread,
Feb 26, 2019, 5:04:38 PM2/26/19
to AdWords API and Google Ads API Forum
Hello, Bharani

Yes, for creating new Youtube media id on my account I'm using google ads scripts in Adwords UI.

And in script below I'm using ONLY Youtube MEDIA id (not youtube VIDEO id).

But I can't change youtube media ids list in my Video ads only UAC via API because it's UAC is Video ads only

2019-02-26 17.41.27.jpg



When I'm trying to change of youtube media ids sets in this type of UAC I'm getting an error:

zeep.exceptions.Fault: [SettingError.YOUTUBE_MEDIA_IDS_REQUIRED_IN_VIDEO_ONLY_UAC @ operations[0].operand.settings[0].youtubeVideoMediaIds; trigger:'[]']

This is my script for mutate:

from googleads import adwords
import os

class GoogleYamlConf:
    def __init__(self):
        self.yaml_path = os.path.abspath(os.path.dirname(__file__))

    def config(self):
        yaml_file = './googleads.yaml'
        return yaml_file


gc = GoogleYamlConf()
yaml_path = gc.config()


class CampaignMutate:
    def __init__(self, adwords_client, campaign_id, video_ids: list = []):
        self.video_ids = video_ids

        self.settings = {
                    'xsi_type': 'UniversalAppCampaignSetting',
                    'youtubeVideoMediaIds': self.video_ids
                }
        self.campaign_service = adwords_client.GetService('CampaignService', version='v201809')

        selector = {
            'fields': ['CampaignId', 'Settings', 'Name'],
            'predicates': [{
                'field': 'CampaignId',
                'operator': 'IN',
                'values': [campaign_id]
            }]
        }

        page = self.campaign_service.get(selector)
        if 'entries' in page:
            for campaign in page['entries']:
                print(campaign)
                self.campaign = campaign
                self.youtubeVideoMediaIds = campaign.settings[1].youtubeVideoMediaIds
        else:
            print('campaign not found')
            # logger.error('campaign not found')

    def remove_media_ids(self):
        video_ids_for = list(set(self.youtubeVideoMediaIds) - set(self.video_ids))

        self.settings = {
            'xsi_type': 'UniversalAppCampaignSetting',
            'youtubeVideoMediaIdsOps': self.video_ids,
        }
        self._update_media_data()
        self.video_ids = video_ids_for
        self.youtubeVideoMediaIds = []
        return self.add_media_ids()

    def add_media_ids(self):
        if len(list(set(self.youtubeVideoMediaIds + self.video_ids))) > 20:
            return False
        self.video_ids = list(set(self.youtubeVideoMediaIds + self.video_ids))

        self.settings = {
            'xsi_type': 'UniversalAppCampaignSetting',
            'youtubeVideoMediaIds': self.video_ids,
        }
        return self._update_media_data()


    def _update_media_data(self):
        operations = [{
            'operator': 'SET',
            'operand': {
                'id': self.campaign.id,
                'settings': self.settings
            }
        }]
        print(operations)
        return self.campaign_service.mutate(operations)['value'][0]['settings'][1]['youtubeVideoMediaIds']


client = adwords.AdWordsClient.LoadFromStorage(yaml_path)
media_ids = [***]
campaign_id = ***

camp = CampaignMutate(client, campaign_id,
media_ids)
res = camp.remove_media_ids()
print(res)



this is campaign object for mutate:

{
    'id': 1714*****,
    'campaignGroupId': None,
    'name': '****',
    'status': None,
    'servingStatus': None,
    'startDate': None,
    'endDate': None,
    'budget': None,
    'conversionOptimizerEligibility': None,
    'adServingOptimizationStatus': None,
    'frequencyCap': None,
    'settings': [
        {
            'Setting.Type': 'GeoTargetTypeSetting',
            'positiveGeoTargetType': 'DONT_CARE',
            'negativeGeoTargetType': 'DONT_CARE'
        },
        {
            'Setting.Type': 'UniversalAppCampaignSetting',
            'appId': '***',
            'appVendor': 'VENDOR_GOOGLE_MARKET',
            'description1': '***',
            'description2': '***',
            'description3': '***',
            'description4': '***',
            'youtubeVideoMediaIds': [
                ***
            ],
            'imageMediaIds': [
                ***
            ],
            'universalAppBiddingStrategyGoalType': 'OPTIMIZE_FOR_TARGET_IN_APP_CONVERSION',
            'youtubeVideoMediaIdsOps': None,
            'imageMediaIdsOps': None,
            'adsPolicyDecisions': []
        }
    ],
    'advertisingChannelType': None,
    'advertisingChannelSubType': None,
    'networkSetting': None,
    'labels': [],
    'biddingStrategyConfiguration': None,
    'campaignTrialType': None,
    'baseCampaignId': None,
    'forwardCompatibilityMap': [],
    'trackingUrlTemplate': None,
    'finalUrlSuffix': None,
    'urlCustomParameters': None,
    'vanityPharma': None,
    'universalAppCampaignInfo': None,
    'selectiveOptimization': None
}

This is operation for SET:

[{'operator': 'SET', 'operand': {'id': 1714***, 'settings': {'xsi_type': 'UniversalAppCampaignSetting', 'youtubeVideoMediaIdsOps': [***]}}}]

And error:

Error summary: {'faultMessage': "[SettingError.YOUTUBE_MEDIA_IDS_REQUIRED_IN_VIDEO_ONLY_UAC @ operations[0].operand.settings[0].youtubeVideoMediaIds; trigger:'[]']", 'requestId': '000582cd1b59248a0a378dc3dd0b464f', 'serviceName': 'CampaignService', 'methodName': 'mutate', 'operations': '1', 'responseTime': '202'}

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/googleads/common.py", line 1382, in MakeSoapRequest
    *packed_args, _soapheaders=soap_headers)['body']['rval']
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/zeep/proxy.py", line 42, in __call__
    self._op_name, args, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", line 132, in send
    return self.process_reply(client, operation_obj, response)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", line 194, in process_reply
    return self.process_error(doc, operation)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", line 299, in process_error
    detail=fault_node.find('detail'))
zeep.exceptions.Fault: [SettingError.YOUTUBE_MEDIA_IDS_REQUIRED_IN_VIDEO_ONLY_UAC @ operations[0].operand.settings[0].youtubeVideoMediaIds; trigger:'[]']

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/i.tirsky/PycharmProjects/googleadw/campaign_mutate.py", line 145, in <module>
    res = camp.remove_media_ids()
  File "/Users/i.tirsky/PycharmProjects/googleadw/campaign_mutate.py", line 58, in remove_media_ids
    self._update_media_data()
  File "/Users/i.tirsky/PycharmProjects/googleadw/campaign_mutate.py", line 82, in _update_media_data

    return self.campaign_service.mutate(operations)['value'][0]['settings'][1]['youtubeVideoMediaIds']
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/googleads/common.py", line 1394, in MakeSoapRequest
    e.detail, errors=error_list, message=e.message)

googleads.errors.GoogleAdsServerFault: [SettingError.YOUTUBE_MEDIA_IDS_REQUIRED_IN_VIDEO_ONLY_UAC @ operations[0].operand.settings[0].youtubeVideoMediaIds; trigger:'[]']


Process finished with exit code 1


In other UACs in my account I can change youtube media list in UAC without any error but those UAC not Video Ads only campaigns

For example:

    'id': 1693****,
    'campaignGroupId': None,
    'name': '****',
    'status': None,
    'servingStatus': None,
    'startDate': None,
    'endDate': None,
    'budget': None,
    'conversionOptimizerEligibility': None,
    'adServingOptimizationStatus': None,
    'frequencyCap': None,
    'settings': [
        {
            'Setting.Type': 'GeoTargetTypeSetting',
            'positiveGeoTargetType': 'DONT_CARE',
            'negativeGeoTargetType': 'DONT_CARE'
        },
        {
            'Setting.Type': 'UniversalAppCampaignSetting',
            'appId': '***',
            'appVendor': 'VENDOR_APPLE_APP_STORE',
            'description1': '***',
            'description2': '***',
            'description3': '***',
            'description4': '***',
            'youtubeVideoMediaIds': [
                5112****,
                5112****,
                5115****
            ],
            'imageMediaIds': [],
            'universalAppBiddingStrategyGoalType': 'OPTIMIZE_FOR_TARGET_IN_APP_CONVERSION',
            'youtubeVideoMediaIdsOps': None,
            'imageMediaIdsOps': None,
         }],
    'advertisingChannelType': None,
    'advertisingChannelSubType': None,
    'networkSetting': None,
    'labels': [],
    'biddingStrategyConfiguration': None,
    'campaignTrialType': None,
    'baseCampaignId': None,
    'forwardCompatibilityMap': [],
    'trackingUrlTemplate': None,
    'finalUrlSuffix': None,
    'urlCustomParameters': None,
    'vanityPharma': None,
    'universalAppCampaignInfo': None,
    'selectiveOptimization': None
}
[{'operator': 'SET', 'operand': {'id': 1693****, 'settings': {'xsi_type': 'UniversalAppCampaignSetting', 'youtubeVideoMediaIdsOps': [5115***]}}}]

Process finished with exit code 0

Thanks


понедельник, 25 февраля 2019 г., 22:42:44 UTC+3 пользователь googleadsapi-forumadvisor написал:

googleadsapi...@google.com

unread,
Feb 27, 2019, 3:22:47 PM2/27/19
to AdWords API and Google Ads API Forum
Hello, 

Based on the error, it looks like you're missing the Youtube media Ids. You will need to do a MediaService.get() to get the specific youtube media Id and then use the UniversalAppSetting to add the new media setting to the campaign. If you're still having an issue, could you please share the API SOAP logs for the MediaService.get() operation and the CampaignService.mutate() operation so I can take a closer look? You may refer to the logging guide here for guidance on how to enable logging. 

Thanks,
Bharani, AdWords API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

i.ti...@corp.mail.ru

unread,
Mar 14, 2019, 11:29:04 AM3/14/19
to AdWords API and Google Ads API Forum
Hello,

Do you have any updates?
I sent all date to you in private message but no one answer to me...

Thanks,

Igor

суббота, 23 февраля 2019 г., 1:56:57 UTC+3 пользователь i.ti...@corp.mail.ru написал:

googleadsapi...@google.com

unread,
Mar 14, 2019, 1:48:42 PM3/14/19
to i.ti...@corp.mail.ru, AdWords API and Google Ads API Forum
Hello Igor, 

I think you missed the response on the forum thread here. Please find my response below:

Based on the error, it looks like you're missing the Youtube media Ids. You will need to do a MediaService.get() to get the specific youtube media Id and then use the UniversalAppSetting to add the new media setting to the campaign. If you're still having an issue, could you please share the API SOAP logs for the MediaService.get() operation and the CampaignService.mutate() operation so I can take a closer look? You may refer to the logging guide here for guidance on how to enable logging. 

Thanks,
Bharani, AdWords API Team
Reply all
Reply to author
Forward
0 new messages