Re: How to update CampaignCriterion in v201109

2012-02-24 Thread Jim McCabe
Actually - in my experience, the API does not handle it well if you remove 
a criterion and then add it back immediately.  We tried three different 
approaches and only the last one worked:

1. Make one call to remove everything, then another call to add back what 
we want.  FAIL.

2. Do everything in one call, placing the REMOVE operations first in the 
array, followed by the ADD operations.  FAIL.

3. Perform a "diff", so that we only have to add or remove the specific 
items that are required.  SUCCESS.

When I say "FAIL", I mean that the end result is that the criterion that we 
attempted to ADD would never appear in the campaign.  The REMOVE operations 
seemed to take precedence.  We were extremely surprised that #1 failed, 
because they were two separate calls, although immediately following each 
other in time.

Jim



On Tuesday, 21 February 2012 02:32:36 UTC-8, Anash P. Oommen wrote:
>
> Hi Sanjay,
>
> Removing everything and adding everything back works too if you don't want 
> to do the merging part. Also, you might want to make the REMOVE and ADD 
> calls separate. I'm not sure of the exact behaviour if you add and remove 
> the same criterion in the same request. (E.g. REMOVE and ADD US country 
> target in the same call.
>
> Cheers,
> Anash P. Oommen,
> AdWords API Advisor.
>
>
On Tuesday, 21 February 2012 02:32:36 UTC-8, Anash P. Oommen wrote:
>
> Hi Sanjay,
>
> Removing everything and adding everything back works too if you don't want 
> to do the merging part. Also, you might want to make the REMOVE and ADD 
> calls separate. I'm not sure of the exact behaviour if you add and remove 
> the same criterion in the same request. (E.g. REMOVE and ADD US country 
> target in the same call.
>
> Cheers,
> Anash P. Oommen,
> AdWords API Advisor.
>
>
On Tuesday, 21 February 2012 02:32:36 UTC-8, Anash P. Oommen wrote:
>
> Hi Sanjay,
>
> Removing everything and adding everything back works too if you don't want 
> to do the merging part. Also, you might want to make the REMOVE and ADD 
> calls separate. I'm not sure of the exact behaviour if you add and remove 
> the same criterion in the same request. (E.g. REMOVE and ADD US country 
> target in the same call.
>
> Cheers,
> Anash P. Oommen,
> AdWords API Advisor.
>
>
On Tuesday, 21 February 2012 02:32:36 UTC-8, Anash P. Oommen wrote:
>
> Hi Sanjay,
>
> Removing everything and adding everything back works too if you don't want 
> to do the merging part. Also, you might want to make the REMOVE and ADD 
> calls separate. I'm not sure of the exact behaviour if you add and remove 
> the same criterion in the same request. (E.g. REMOVE and ADD US country 
> target in the same call.
>
> Cheers,
> Anash P. Oommen,
> AdWords API Advisor.
>
>
On Tuesday, 21 February 2012 02:32:36 UTC-8, Anash P. Oommen wrote:
>
> Hi Sanjay,
>
> Removing everything and adding everything back works too if you don't want 
> to do the merging part. Also, you might want to make the REMOVE and ADD 
> calls separate. I'm not sure of the exact behaviour if you add and remove 
> the same criterion in the same request. (E.g. REMOVE and ADD US country 
> target in the same call.
>
> Cheers,
> Anash P. Oommen,
> AdWords API Advisor.
>
>
On Tuesday, 21 February 2012 02:32:36 UTC-8, Anash P. Oommen wrote:
>
> Hi Sanjay,
>
> Removing everything and adding everything back works too if you don't want 
> to do the merging part. Also, you might want to make the REMOVE and ADD 
> calls separate. I'm not sure of the exact behaviour if you add and remove 
> the same criterion in the same request. (E.g. REMOVE and ADD US country 
> target in the same call.
>
> Cheers,
> Anash P. Oommen,
> AdWords API Advisor.
>
>
On Tuesday, 21 February 2012 02:32:36 UTC-8, Anash P. Oommen wrote:
>
> Hi Sanjay,
>
> Removing everything and adding everything back works too if you don't want 
> to do the merging part. Also, you might want to make the REMOVE and ADD 
> calls separate. I'm not sure of the exact behaviour if you add and remove 
> the same criterion in the same request. (E.g. REMOVE and ADD US country 
> target in the same call.
>
> Cheers,
> Anash P. Oommen,
> AdWords API Advisor.
>
>
On Tuesday, 21 February 2012 02:32:36 UTC-8, Anash P. Oommen wrote:
>
> Hi Sanjay,
>
> Removing everything and adding everything back works too if you don't want 
> to do the merging part. Also, you might want to make the REMOVE and ADD 
> calls separate. I'm not sure of the exact behaviour if you add and remove 
> the same criterion in the same request. (E.g. REMOVE and ADD US country 
> target in the same call.
>
> Cheers,
> Anash P. Oommen,
> AdWords API Advisor.
>
>
On Tuesday, 21 February 2012 02:32:36 UTC-8, Anash P. Oommen wrote:
>
> Hi Sanjay,
>
> Removing everything and adding everything back works too if you don't want 
> to do the merging part. Also, you might want to make the REMOVE and ADD 
> calls separate. I'm not sure of the exact behaviour if you add and remove 
> the same criterion in the same request. (E.g

Re: How to update CampaignCriterion in v201109

2012-02-21 Thread Anash P. Oommen
Hi Sanjay,

Removing everything and adding everything back works too if you don't want 
to do the merging part. Also, you might want to make the REMOVE and ADD 
calls separate. I'm not sure of the exact behaviour if you add and remove 
the same criterion in the same request. (E.g. REMOVE and ADD US country 
target in the same call.

Cheers,
Anash P. Oommen,
AdWords API Advisor.

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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


Re: How to update CampaignCriterion in v201109

2012-02-16 Thread Sanjay Vel
I wrote my update code like this. Is this code was right? I don't want
to merge the criterions which takes more conditions to check rather
than remove and add campaignCriterions.

require 'rubygems'
require 'adwords_api'

API_VERSION = :v201109

adwords = AdwordsApi::Api.new

campaign_criterion_srv =
adwords.service(:CampaignCriterionService, API_VERSION)

campaign_id = '562911'.to_i

fields = ["Address", "AgeRangeType", "Argument",
  "CampaignId", "CarrierCountryCode", "CarrierName",
  "ContentLabelType", "CriteriaType", "DisplayType",
  "GenderType", "GeoPoint", "Id", "IsObsolete",
  "KeywordMatchType", "KeywordText", "LanguageCode",
  "LanguageName", "LocationName", "Operand", "ParentLocations",
  "Path", "PlacementUrl", "PlatformName", "RadiusDistanceUnits",
  "RadiusInUnits", "Text", "UserInterestId", "UserInterestName",
  "UserListId", "UserListMembershipStatus", "UserListName",
  "Vertices"]

selector = {
  :predicates => [
:field => 'CampaignId',
:operator => 'EQUALS',
:values => [campaign_id]
  ],
  :fields => fields
}

response = campaign_criterion_srv.get(selector)
existing_criterions = response[:entries]
new_criterions = [  {:xsi_type => 'Gender', :id => 10},
  {:xsi_type => 'Gender', :id => 11}]

operations = []

if(!existing_criterions.empty?)
  puts "aa #{existing_criterions}"
  existing_criterions.each do |criterions|
criterion = criterions[:criterion]
if(criterion[:xsi_type] != "Platform")
  criterion.keys.each do |key|
if(!(key == :id || key == :xsi_type))
criterion.delete(key)
end

operations << {
  :operator => 'REMOVE',
  :operand => {
:campaign_id => campaign_id,
:criterion => criterion
  }
}
  end
end
  end
end

new_criterions.each do |new_criterion|
  operations << {
:operator => 'ADD',
:operand => {
  :xsi_type => 'NegativeCampaignCriterion',
  :campaign_id => campaign_id,
  :criterion => new_criterion
}
  }
end

response = campaign_criterion_srv.mutate(operations)

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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


Re: How to update CampaignCriterion in v201109

2012-02-14 Thread Anash P. Oommen
Hi Sanjay,

CampaignCriterionService doesn't support SET operator. You have to ADD the 
targets you need, REMOVE the targets you don't need. A typical approach 
would be to get() all your targets, and then merge the list with your 
desired list. Remove all the common items between the two lists. Do an ADD 
for any items you find new in the list. Do a REMOVE for any item that is 
not required.

Hope that helps. Let me know if you have more questions.

Cheers,
Anash P. Oommen,
AdWords API Advisor.

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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


How to update CampaignCriterion in v201109

2012-02-14 Thread Sanjay Vel
I am trying to update the CampaignCriterion using the operation

operation = {
   :operator => 'SET',
   :operand => {
  :xsi_type => 'NegativeCampaignCriterion',
  :campaign_id => campaign_id,
  :criterion => {:xsi_type => 'Gender', :id => 11}
}
}

I am stuck with the following error during mutate action

OperatorError.OPERATOR_NOT_SUPPORTED @ operations[0]

Is 'SET' operator supported in CampaignCriterionOperation? If yes,
where I am doing wrong? else How to update CampaignCriterion?

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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