// Get AdWordsUser from "~/adwords.properties".
AdWordsUser user = new AdWordsUser();
// Get the AdExtensionOverrideService.
AdExtensionOverrideServiceInterface adExtensionOverrideService =
user.getService(AdWordsService.V201306.AD_EXTENSION_OVERRIDE_SERVICE);
long adId = Long.parseLong("INSERT_AD_ID_HERE");
long campaignAdExtensionId = Long.parseLong("INSERT_CAMPAIGN_AD_EXTENSION_ID_HERE");
// Create ad extension override.
AdExtensionOverride adExtensionOverride = new AdExtensionOverride();
adExtensionOverride.setAdId(adId);
// Create ad extension using existing id.
AdExtension adExtension = new AdExtension();
adExtension.setId(campaignAdExtensionId);
adExtensionOverride.setAdExtension(adExtension);
// Create operations.
AdExtensionOverrideOperation operation = new AdExtensionOverrideOperation();
operation.setOperand(adExtensionOverride);
operation.setOperator(Operator.ADD);
AdExtensionOverrideOperation[] operations = new AdExtensionOverrideOperation[] {operation};
// Add ad extension override.
AdExtensionOverrideReturnValue result = adExtensionOverrideService.mutate(operations);
// Display ad extension overrides.
if (result != null && result.getValue() != null) {
for (AdExtensionOverride adExtensionOverrideResult : result.getValue()) {
System.out.println("Ad extension override with ad id \""