2

I'm trying to create an asset (CreativeAsset) to be used in a template Creative later. I cannot find in the documentation any way to create the asset itself, only to provide the base64 bytes, but I'd like to use this asset in multiple places, so I would prefer to load it once..Is there a way to create only a CreativeAsset?

https://developers.google.com/doubleclick-publishers/docs/reference/v201705/CreativeService.CreativeAsset

Dory Zidon
  • 10,497
  • 2
  • 25
  • 39

2 Answers2

1

Here is the solution from the DFP API team:

A CreativeAsset must be created as a part of a creative. There is no dedicated service to create a CreativeAsset alone. But then, you can use the assetId to copy a CreativeAsset to a new creative. Basically, you can first create a creative, then get the creative asset's assetId and use it to create multiple creatives

Oleg Kuralenko
  • 11,003
  • 1
  • 30
  • 40
0

This is a code example using python:

with open(f, "rb") as html_file:
        html_file_data = base64.b64encode(html_file.read())
        html_file_data = html_file_data.decode("utf-8")

# USING TEMPLATE

creative1 = {
    'xsi_type': 'TemplateCreative',
    'name': '',
    'advertiserId': '',
    'size': {'width': 1, 'height': 1},
    'creativeTemplateId': '',
    'creativeTemplateVariableValues': [
        {
            'xsi_type': 'AssetCreativeTemplateVariableValue',
            'uniqueName': 'HTMLFile',
            'asset': {
                'assetByteArray': html_file_data,
                'fileName': ''
            }
        }
        # other variables 
    ]
}
# USING CUSTOM
creative2 = {
    'xsi_type': 'CustomCreative',
    'name': '',
    'advertiserId': '',
    'size': {'width': 1, 'height': 1},
    'destinationUrl': '',
    'customCreativeAssets': []
}

creative2['customCreativeAssets'].append({
    'xsi_type': 'CustomCreativeAsset',
    'macroName': '',
    'asset': {
        'assetByteArray': html_file_data,
        'fileName': ''
    }
})

creative_service = dfp_client.GetService('CreativeService', version='v201702')

upload_creative1 = creative_service.createCreatives(creative1)

upload_creative2 = creative_service.createCreatives(creative2)

I hope this works.

felipk
  • 154
  • 7
  • You're creating a creative asset from scratch via assetByteArray, the question was about reusing an asset (not the encoded data) multiple times. Do you have an idea how it could be accomplished? – Oleg Kuralenko Oct 18 '17 at 15:41