Hello,
the code below gives this error:
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;
}
Il giorno giovedì 5 marzo 2020 20:56:13 UTC+1, adsapiforumadvisor ha
scritto:
>
> Hi Roberto,
>
> That is just an example for you to base your code off of. You should
> replace it with DynamicSearchAd
> <https://developers.google.com/adwords/api/docs/reference/v201809/AdService.DynamicSearchAd>
> ad
> type and set the Description1
> <https://developers.google.com/adwords/api/docs/reference/v201809/AdService.DynamicSearchAd#description1_1>
>
> and Description2
> <https://developers.google.com/adwords/api/docs/reference/v201809/AdService.DynamicSearchAd#description2_1>
>
> fields to your desired value.
>
> Regards,
> Mitchell
> Google Ads API Team
>
> ref:_00D1U1174p._5001UXTvSx:ref
>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/cd882281-b0e2-4d38-90ab-c93e791b765a%40googlegroups.com.