Hello assaf,

As this is IP exclusion, you need to add a NegativeCampaignCriterion 
instead of CampaignCriterion:

  
https://developers.google.com/adwords/api/docs/reference/v201402/CampaignCriterionService.NegativeCampaignCriterion


-Danial, AdWords API Team.


On Thursday, May 8, 2014 11:55:06 AM UTC+4, assaf wrote:
>
> Hi,
>
> I am trying to usethe newly added feature - IpBlock .
> I tried to add a new IP to be blocked for a campaign and get the following 
> error -
>
> AxisFault
>  faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
>  faultSubcode: 
>  faultString: [CriterionError.CANNOT_ADD_CRITERIA_TYPE @ 
> operations[0].operand.criterion]
>  faultActor: 
>  faultNode: 
>  faultDetail: 
> {https://adwords.google.com/api/adwords/cm/v201402}ApiExceptionFault:<message>[CriterionError.CANNOT_ADD_CRITERIA_TYPE
>  
> @ 
> operations[0].operand.criterion]</message><ApplicationException.Type>ApiException</ApplicationException.Type><errors
>  
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xsi:type="CriterionError"><fieldPath>operations[0].operand.criterion</fieldPath><trigger/><errorString>CriterionError.CANNOT_ADD_CRITERIA_TYPE</errorString><ApiError.Type>CriterionError</ApiError.Type><reason>CANNOT_ADD_CRITERIA_TYPE</reason></errors>
>
> [CriterionError.CANNOT_ADD_CRITERIA_TYPE @ operations[0].operand.criterion]
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown 
> Source)
> at java.lang.reflect.Constructor.newInstance(Unknown Source)
> at java.lang.Class.newInstance0(Unknown Source)
> at java.lang.Class.newInstance(Unknown Source)
> at 
> org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)
>
> My code is standard -
>
>                              Credential oAuth2Credential = new 
> OfflineCredentials.Builder()
>         .forApi(Api.ADWORDS)
>         .fromFile()
>         .build()
>         .generateCredential();
>
>     // Construct an AdWordsSession.
>     AdWordsSession session = new AdWordsSession.Builder()
>         .fromFile()
>         .withOAuth2Credential(oAuth2Credential)
>         .build();
>         
>     session.setClientCustomerId(pClientID);
>     
>     AdWordsServices adwordsServices = new AdWordsServices();
>     // Get the CampaignService.
>     CampaignCriterionServiceInterface campaignCriterionService = 
> adwordsServices.get(session,                                     
> CampaignCriterionServiceInterface.class);
>
>       Long campaignId = Long.valueOf(pCampaignID);
>       
>      
>       if (null != pIP) {          
>       
>            IpBlock ip = new IpBlock();
>       ip.setIpAddress(pIP);
>
> // not needed      ip.setType(CriterionType.IP_BLOCK);
> // not needed      ip.setId((long)123456);
>         
>       List<CampaignCriterionOperation> operations = new 
> ArrayList<CampaignCriterionOperation>();
>       for (Criterion criterion : new Criterion[] {ip}) {
>         CampaignCriterionOperation operation = new 
> CampaignCriterionOperation();
>         CampaignCriterion campaignCriterion = new CampaignCriterion();
>         campaignCriterion.setCampaignId(campaignId);
>         
>         
>         campaignCriterion.setCriterion(criterion);
>      
>         operation.setOperand(campaignCriterion);
>         operation.setOperator(Operator.ADD);
>         operations.add(operation);
>       }
>       
>       CampaignCriterionReturnValue result =
>           campaignCriterionService.mutate(operations
>               .toArray(new CampaignCriterionOperation[operations.size()]));
>                       }
>
> I would appreciate some guidance.
>
> Thanks.
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to