Re: Adding Bulk Campigns, AdGroups and Keywords

2015-04-02 Thread Nadine Sundquist (AdWords API Team)
Hello,

The Adwords API does not have the ability to roll back successful 
operations or create nested operations. However, the AdWords API does 
support a feature called Partial Failure 
 where 
you can submit a collection of operations and do error handling on only the 
failed operations. The successful operations will commit, but the failed 
operations will come back to you with an explanation. You can then 
determine what to do. For example, if one of your campaigns operations 
fail, you can avoid any operations that rely on that campaign operation. 
Here's a snippet of the Java code example 

:

// Enable partial failure.
session 
.setPartialFailure
 
(true);


// Do some operations here.

// Iterate through the result to see if any of the operations failed.

for (ApiError 

 apiError 

 : result 
.getPartialFailureErrors
 
())
 {
  Matcher 

 matcher 

 = operationIndexPattern 
.matcher
 
(apiError
 
.getFieldPath
 
());
  if (matcher 


Adding Bulk Campigns, AdGroups and Keywords

2015-04-02 Thread pcj
Hi 

  I am developing app in java where I need to Add Campaigns within those 
Campaigns AdGroups, and for those AdGroups their repesctive keywords. So fo 
adding Ad Group we need Campaign ID, and for adding keywords need AdGroup 
ID.

So for now I am doing like this : 

  First Adding Batch of Campiagns like below :
   CampaignOperation[] campaignOperations = new CampaignOperation[ ] { 
cOp1, cOp2, cOp3};
// Add campaigns.
   CampaignReturnValue addResult = 
campaignService.mutate(campaignOperations);

   // Retriving IDs for added campians

  Then I Add AdGroups To Respective Campaigns using Campaign IDs I got, as 
below :

AdGroupOperation[] adAdGroupsOperations = new AdGroupOperation[] { 
cOp1AdGrp1, cOp1AdGrp2, cOp1AdGrp3, cOp2AdGrp1, cOp2AdGrp2, 
cOp3AdGrp1,};

// Add ad groups.
AdGroupReturnValue result = adGroupService.mutate(adAdGroupsOperations);

// I retriev Group IDs here 

  Then I Add Keywords To Respective AdGroups using AdGroup IDs I got, as 
below :

  AdGroupCriterionOperation[] keywordsOperations = new 
AdGroupCriterionOperation[ cOp1AdGrp1KeywrdOp1, 
cOp1AdGrp1KeywrdOp1, .., cOp[N]AdGrp[N]KeywrdOp[N];

  // Add keywords.
   AdGroupCriterionReturnValue result = adGroupCriterionService
.mutate(keywordsOperations);

Above code will do like : 

1] Adds Campaigns,
2] Adds AdGroups to respective Campaigns,
3] Adds Keywords to Respective AdGroups,

Now my problem is that if any of these fails I need to roll back,
Is there any way to rollback changes made by perticular session 


OR

Is there any way that I can do like this :
1] Create nested operations

mainOperation {
 CampaignOperation1 {
AdGroupOperation1, {
  KeywordOperation1,
  KeywordOperation2, 
}
AdGroupOperation2, {
  KeywordOperation1,
  KeywordOperation2,
} 
AdGroupOperation3, {
  KeywordOperation1,
  KeywordOperation2,
} 
AdGroupOperation4, {
  KeywordOperation1,
  KeywordOperation2,
} 
 },
 CampaignOperation1 {
AdGroupOperation1, {
  KeywordOperation1,
  KeywordOperation2, 
}
AdGroupOperation2, {
  KeywordOperation1,
  KeywordOperation2,
} 
AdGroupOperation3, {
  KeywordOperation1,
  KeywordOperation2,
} 
AdGroupOperation4, {
  KeywordOperation1,
  KeywordOperation2,
} 
 }
}

2] And then add these operations in single batch.


Is this possible, and how ? 


-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 http://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/883fdcc1-a9ee-41ee-8f8b-e3ba64ecf2db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.