When I using .net lib libary from github, result error OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE. How to fix this problem? Thanks so much!.
using Google.Api.Ads.AdWords.Lib; using Google.Api.Ads.AdWords.v201802; using System; using System.Collections.Generic; namespace Google.Api.Ads.AdWords.Examples.CSharp.v201802 { /// <summary> /// This code example adds various types of targeting criteria to a campaign. /// To get a list of campaigns, run GetCampaigns.cs. /// </summary> public class AddCampaignTargetingCriteria : ExampleBase { /// <summary> /// Main method, to run this code example as a standalone application. /// </summary> /// <param name="args">The command line arguments.</param> public static void Main(string[] args) { AddCampaignTargetingCriteria codeExample = new AddCampaignTargetingCriteria(); Console.WriteLine(codeExample.Description); try { long campaignId = long.Parse("1341670265"); string feedIdText = "INSERT_LOCATION_FEED_ID_HERE"; long? feedId = null; long temp; if (long.TryParse(feedIdText, out temp)) { feedId = temp; } codeExample.Run(new AdWordsUser(), campaignId, feedId); } catch (Exception e) { Console.WriteLine("An exception occurred while running this code example. {0}", ExampleUtilities.FormatException(e)); } } /// <summary> /// Returns a description about the code example. /// </summary> public override string Description { get { return "This code example adds various types of targeting criteria to a campaign. To " + "get a list of campaigns, run GetCampaigns.cs."; } } /// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="campaignId">Id of the campaign to which targeting criteria /// are added.</param> /// <param name="feedId">ID of a feed that has been configured for location /// targeting, meaning it has an ENABLED FeedMapping with criterionType of /// 77. Feeds linked to a GMB account automatically have this FeedMapping. /// If you don't have such a feed, set this value to null.</param> public void Run(AdWordsUser user, long campaignId, long? feedId) { using (CampaignCriterionService campaignCriterionService = (CampaignCriterionService)user.GetService( AdWordsService.v201802.CampaignCriterionService)) { // Create locations. The IDs can be found in the documentation or // retrieved with the LocationCriterionService. Location california = new Location() { id = 21137L }; Location mexico = new Location() { id = 2484L }; // Create languages. The IDs can be found in the documentation or // retrieved with the ConstantDataService. Language english = new Language() { id = 1000L //1040 }; Language vietnam = new Language() { id = 1040 }; Language spanish = new Language() { id = 1003L }; List<Criterion> criteria = new List<Criterion>() { california, mexico, english, spanish }; // Distance targeting. Area of 10 miles around the locations in the location feed. if (feedId != null) { LocationGroups radiusLocationGroup = new LocationGroups() { feedId = feedId.Value, matchingFunction = new Function() { @operator = FunctionOperator.IDENTITY, lhsOperand = new FunctionArgumentOperand[] { new LocationExtensionOperand() { radius = new ConstantOperand() { type = ConstantOperandConstantType.DOUBLE, unit = ConstantOperandUnit.MILES, doubleValue = 10 } } } } }; criteria.Add(radiusLocationGroup); } // Create operations to add each of the criteria above. List<CampaignCriterionOperation> operations = new List<CampaignCriterionOperation>(); foreach (Criterion criterion in criteria) { CampaignCriterionOperation operation = new CampaignCriterionOperation() { operand = new CampaignCriterion() { campaignId = campaignId, criterion = criterion }, @operator = Operator.ADD }; operations.Add(operation); } // Add a negative campaign criterion. CampaignCriterion negativeCriterion = new NegativeCampaignCriterion() { campaignId = campaignId, criterion = new Keyword() { text = "jupiter cruise", matchType = KeywordMatchType.BROAD } }; CampaignCriterionOperation negativeCriterionOperation = new CampaignCriterionOperation() { operand = negativeCriterion, @operator = Operator.ADD }; operations.Add(negativeCriterionOperation); try { // Set the campaign targets. CampaignCriterionReturnValue retVal = campaignCriterionService.mutate( operations.ToArray()); if (retVal != null && retVal.value != null) { // Display campaign targets. foreach (CampaignCriterion criterion in retVal.value) { Console.WriteLine("Campaign criteria of type '{0}' was set to campaign with" + " id = '{1}'.", criterion.criterion.CriterionType, criterion.campaignId); } } } catch (Exception e) { throw new System.ApplicationException("Failed to set Campaign criteria.", e); } } } } } -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and Google+: https://googleadsdeveloper.blogspot.com/ https://plus.google.com/+GoogleAdsDevelopers/posts =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords 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 Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@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/dd70e044-0739-4ae7-8d10-165e1b0f9589%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.