/// <summary>Snippet for MutateFeedItemSets</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateFeedItemSets() { // Create client FeedItemSetServiceClient feedItemSetServiceClient = FeedItemSetServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <FeedItemSetOperation> operations = new FeedItemSetOperation[] { new FeedItemSetOperation(), }; // Make the request MutateFeedItemSetsResponse response = feedItemSetServiceClient.MutateFeedItemSets(customerId, operations); }
/// <summary>Snippet for MutateFeedItemSets</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateFeedItemSetsRequestObject() { // Create client FeedItemSetServiceClient feedItemSetServiceClient = FeedItemSetServiceClient.Create(); // Initialize request argument(s) MutateFeedItemSetsRequest request = new MutateFeedItemSetsRequest { CustomerId = "", Operations = { new FeedItemSetOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateFeedItemSetsResponse response = feedItemSetServiceClient.MutateFeedItemSets(request); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads API client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <param name="feedId">The Feed ID for creating the feed item set.</param> public void Run(GoogleAdsClient client, long customerId, long feedId) { // Get the FeedItemSetService. FeedItemSetServiceClient feedItemService = client.GetService( Services.V6.FeedItemSetService); FeedItemSet feedItemSet = new FeedItemSet() { Feed = ResourceNames.Feed(customerId, feedId), DisplayName = "Feed Item Set #" + ExampleUtilities.GetRandomString(), }; // A feed item set can be created as a dynamic set by setting an optional filter // field below. If your feed is a location extension, uncomment the code that calls // DynamicLocationSetFilter. If instead your feed is an affiliate extension, // uncomment the code that sets the DynamicAffiliateLocationSetFilter instead. // 1) Location extension. //feedItemSet.DynamicLocationSetFilter = new DynamicLocationSetFilter() //{ // // Dynamic location sets support filtering locations based on business name // // and/or labels. If both are specified, the feed item set will only include // // locations that satisfy both types of filters. // BusinessNameFilter = new BusinessNameFilter() // { // BusinessName = "INSERT_YOUR_BUSINESS_NAME_HERE", // FilterType = FeedItemSetStringFilterType.Exact, // }, // // Adds a filter by feed item label resource name. If multiple labels are // // specified, the feed item set will only include feed items with all of the // // specified labels. // Labels = { "INSERT_BUSINESS_LABEL_HERE" } //}; // 2) Affiliate extension. //feedItemSet.DynamicAffiliateLocationSetFilter = new DynamicAffiliateLocationSetFilter() //{ // ChainIds = { long.Parse("INSERT_CHAIN_ID_HERE") } //}; // Constructs an operation that will create a new feed item set. FeedItemSetOperation operation = new FeedItemSetOperation() { Create = feedItemSet }; try { // Issues a mutate request to add the feed item set on the server. MutateFeedItemSetsResponse response = feedItemService.MutateFeedItemSets(customerId.ToString(), new[] { operation }); // Prints the resource names of the added feed item sets. foreach (MutateFeedItemSetResult addedFeedItemSet in response.Results) { Console.WriteLine("Created a feed item set with resource name " + $"'{addedFeedItemSet.ResourceName}'"); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }