Request failed due to ApiException. Underlying ApiErrors:
Error 0: RequiredError{apiErrorType=RequiredError, errorString=RequiredError.REQUIRED, fieldPath=operations[0].operand.status, fieldPathElements=[FieldPathElement{field=operations, index=0}, FieldPathElement{field=operand}, FieldPathElement{field=status}], reason=REQUIRED, trigger=}
Error 1: AdError{apiErrorType=AdError, errorString=AdError.CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR, fieldPath=operations[0].operand.ad, fieldPathElements=[FieldPathElement{field=operations, index=0}, FieldPathElement{field=operand}, FieldPathElement{field=ad}], reason=CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR, trigger=}
what is the problem?
thanks :)
public Boolean doUpdateAd(AdWordsServicesInterface adWordsServices, AdWordsSession session,
Long adGroupId, Long adId,
String description1, String description2) throws ApiException, RemoteException {
AdGroupAdServiceInterface adGroupAdService = adWordsServices.get(session, AdGroupAdServiceInterface.class);
// Create ad with updated status.
DynamicSearchAd ad = new DynamicSearchAd();
ad.setId(adId);
ad.setDescription1(description1);
ad.setDescription2(description1);
AdGroupAd adGroupAd = new AdGroupAd();
adGroupAd.setAdGroupId(adGroupId);
adGroupAd.setAd(ad);
//adGroupAd.setStatus(AdGroupAdStatus.PAUSED);
// Create operations.
AdGroupAdOperation operation = new AdGroupAdOperation();
operation.setOperand(adGroupAd);
operation.setOperator(Operator.SET);
AdGroupAdOperation[] operations = new AdGroupAdOperation[] {operation};
// Update ad.
AdGroupAdReturnValue result = adGroupAdService.mutate(operations);
// Display ads.
for (AdGroupAd adGroupAdResult : result.getValue()) {
System.out.printf("Ad with ID %d, type '%s', and status '%s' was updated.%n",
adGroupAdResult.getAd().getId(), adGroupAdResult.getAd().getAdType(),
adGroupAdResult.getStatus());
}
return true;
}