Hi friends!

I am currently trying to get html5 upload to work, but im running into an 
issue when i try to create an ad i can connect to an adgroup.

Let me explain.

1. Create a campaign

2. Create an adgroup

3. Upload html 5

4. Create ad with html 5 ad.

Im stuck on 4 where i am trying to use the api like this from a c# client.

        public static void AssetConnectionToAd(string 
mediaBundleResourceName, string adgroup)
        {
            AdGroupAdServiceClient adgroupServiceClient = client.GetService(
Services.V2.AdGroupAdService);
            var req = new MutateAdGroupAdsRequest();
            req.Operations.Add(new AdGroupAdOperation {
                Create = new AdGroupAd
                {
                    Ad = new Ad
                    {                        
                        
                        DisplayUploadAd = new DisplayUploadAdInfo
                        {
                            DisplayUploadProductType = 
DisplayUploadProductTypeEnum.Types.DisplayUploadProductType.
DynamicHtml5CustomAd,
                            MediaBundle = new AdMediaBundleAsset
                            {
                                Asset = mediaBundleResourceName
                            }
                        },                        
                    },
                    AdGroup = adgroup,                  
                    
                }
                
            });
            req.CustomerId = customerId.ToString();
           var ad = adgroupServiceClient.MutateAdGroupAds(req);
        }

If i try to connect this i get an error message:
"Resource name 'customers/6282670156/mediaFiles/26325216408' is malformed: 
expected 'customers/{customer_id}/assets/{part_1}'."

I am suspecting im uploading it wrong since its creating the resource in 
another place with /mediafiles and not /assets.

My upload method:

        public static MutateMediaFileResult UploadHtml5(string filepath)
        {
            MediaFileServiceClient mediaService = client.GetService(Services
.V2.MediaFileService);

            MutateMediaFilesRequest req = new MutateMediaFilesRequest();

            var data = File.ReadAllBytes(filepath);
            req.Operations.Add(new MediaFileOperation()
            {
                Create = new MediaFile
                {
                    MediaBundle = new MediaBundle
                    {
                        Data = ByteString.CopyFrom(data)                   
    
                    },
                    Type = MediaTypeEnum.Types.MediaType.MediaBundle       
            
                    
                }
            });
            req.CustomerId = customerId.ToString();
          var result = mediaService.MutateMediaFiles(req);            
            return result.Results.First();               
            
        }

This will return 'customers/6282670156/mediaFiles/26325216408'

I have tested my bundle from the google ads ui and run a succesful campaign 
with the asset so it is working, however i think im using the wrong upload 
service.

Can anyone advise? 

Thanks

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/4146cbde-503d-4bde-adb4-8d3cdaf65839%40googlegroups.com.

Reply via email to