Issue creating an Ad for App Campaign

97 views
Skip to first unread message

Diego Toro

unread,
Feb 13, 2020, 4:36:05 AM2/13/20
to AdWords API and Google Ads API Forum
Hello I've been trying several ways to create an  Ad for App Campaign as described in: 


I need to be able to create text, image, and video ads, first I tried toc reate a text ad but I get the following error:


Response
--------
Headers: Metadata(content-type=application/grpc,request-id=EE7bwQ-Em8XCqWb4o5cUVA,date=Thu, 13 Feb 2020 09:11:49 GMT,alt-svc=quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000)
Body: null
Failure message: errors {
  error_code {
    collection_size_error: TOO_FEW
  }
  message: "Too few."
  trigger {
    string_value: ""
  }
  location {
    field_path_elements {
      field_name: "operations"
      index {
      }
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "ad"
    }
    field_path_elements {
      field_name: "app_ad"
    }
    field_path_elements {
      field_name: "headlines"
    }
    field_path_elements {
      field_name: "pinned_field"
    }
  }
}
errors {
  error_code {
    request_error: UNKNOWN
  }
  message: "The error code is not in this version."
  trigger {
    string_value: "HEADLINE_1"
  }
  location {
    field_path_elements {
      field_name: "operations"
      index {
      }
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "ad"
    }
    field_path_elements {
      field_name: "app_ad"
    }
    field_path_elements {
      field_name: "headlines"
      index {
      }
    }
    field_path_elements {
      field_name: "pinned_field"
    }
  }
}
errors {
  error_code {
    collection_size_error: TOO_FEW
  }
  message: "Too few."
  trigger {
    string_value: ""
  }
  location {
    field_path_elements {
      field_name: "operations"
      index {
      }
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "ad"
    }
    field_path_elements {
      field_name: "app_ad"
    }
    field_path_elements {
      field_name: "descriptions"
    }
    field_path_elements {
      field_name: "pinned_field"
    }
  }
}

According to other examples for text ads pinned field is not mandatory for text assets, and if I set it with any of the values from ServedAssetFieldType, such as ServedAssetFieldTypeEnum.ServedAssetFieldType.HEADLINE_1. But as you can see in the response, it says the value is unkwown.

Also, there is another issue when I set any status to AdGroupAd, it says the operation is nt permitted for the campaign then.

We really need help with this becaus eyou don't have any example for complete App campaigns creation.

This is the code:

public Ad uploadAd(CompanyAd ad, Long customerId, Long adGroupId) {
   AdGroupAdOperation adGroupAdOperation = googleAcAdGroupAdOperationFactory.buildAdGroupAdOperation(ad);

final MutateAdGroupAdResult uploadResult = googleAcClient.executeUploadAdOperation(ad, adGroupAdOperation);

return CompanyAd;

}

public AdGroupAdOperation buildAdGroupAdOperation(Ad ad, Long customerId, Long adGroupId) {
   AdGroupAd.Builder adGroupAdBuilder = AdGroupAd.newBuilder().setAdGroup(StringValue.of(ResourceNames.adGroup(customerId, adGroupId)));
AdGroupAdOperation.Builder opBuilder = AdGroupAdOperation.newBuilder();

if (StringUtils.isNotEmpty(ad.getPartnerRemoteId())) {
adGroupAdBuilder.setResourceName(ResourceNames.adGroupAd(customerId, adGroupId, Long.valueOf(ad.getPartnerRemoteId())));
}

adGroupAdBuilder.setAd(buildHeadlineTextAd(ad));
   // adGroupAdBuilder.setStatus(AdGroupAdStatusEnum.AdGroupAdStatus.PAUSED);
adGroupAdBuilder.setAdGroup(StringValue.
of(ResourceNames.adGroup(customerId, adGroupId)));
opBuilder.setCreate(adGroupAd);

}

private Ad buildHeadlineTextAd(Ad ad) {
final AdContent adContent = ad.getHeadLine();

AppAdInfo.Builder appAdInfo = AppAdInfo.newBuilder();
appAdInfo.addHeadlinesBuilder().setText(StringValue.of(adContent.getTitle()))
.setPinnedField(ServedAssetFieldTypeEnum.ServedAssetFieldType.HEADLINE_1);

Ad.Builder adBuilder = Ad.newBuilder();
adBuilder.setName(StringValue.of("Headline Ad # " + System.currentTimeMillis()));
adBuilder.setAppAd(appAdInfo);

   return adBuilder.build();
}

public MutateAdGroupAdResult executeUploadAdOperation(Ad originAd, AdGroupAdOperation adGroupAdOperation) {
GoogleAdsClient googleAdsClient = GoogleAdsClient.newBuilder().fromProperties(getGoogleAdsClientProperties()).build();

try (AdGroupAdServiceClient adGroupAdServiceClient = googleAdsClient.getLatestVersion().createAdGroupAdServiceClient()) {

final String consumerId = originAd.getAdset().getCampaign().getAccount().getPartnerRemoteId();
final MutateAdGroupAdsResponse mutateAdGroupsResponse = adGroupAdServiceClient.mutateAdGroupAds(consumerId, Collections.singletonList(adGroupAdOperation));

return mutateAdGroupsResponse.getResults(0);
}
}
 

Thank you

davi...@google.com

unread,
Feb 13, 2020, 6:40:35 AM2/13/20
to AdWords API and Google Ads API Forum
Look at this recently posted example in Python: https://github.com/googleads/google-ads-python/blob/master/examples/advanced_operations/add_app_campaign.py


Setting the HEADLINE_1 property on the ad_text_asset will indeed cause the error you discovered. This was recently filed as an internal bug. In fact, it is better if you do not set any values for the ad_text_asset.ServedAssetFieldType attribute. The headline needs to be set on parent .headlines property.

-David

Reply all
Reply to author
Forward
0 new messages