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