Update stardate/enddate of a campaign and Descr1, Descr2 of a Dynamic search Ad

62 views
Skip to first unread message

Roberto

unread,
Mar 3, 2020, 3:52:43 AM3/3/20
to AdWords API and Google Ads API Forum
Hi,

how to 

-Update stardate/enddate of a campaign and 
-Descr1, Descr2 of a Dynamic search Ad in Java?

Google Examples are full of creation but a few for updating objects.

thanks for your help!
Roberto 

Google Ads API Forum Advisor Prod

unread,
Mar 3, 2020, 5:07:50 PM3/3/20
to ilmio...@gmail.com, adwor...@googlegroups.com
Hi Roberto,

Thank you for reaching out. If you're using AdWords API, you can update the start date and end date by using the CampaignService SET operation and assign the Campaign startDate and endDate. You can follow this example. To update the Ad, you can use the AdGroupAdService SET operation and set the description1 and description2. You can follow this example.

If you're using Google Ads API, you will follow a similar format but with the CampaignService and AdGroupAdService. You can follow this example to update the campaign and this example to update the ad.

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5001UXTvSx:ref

Roberto

unread,
Mar 5, 2020, 10:02:54 AM3/5/20
to AdWords API and Google Ads API Forum
Hi,

pause-ad is for a generic Ad,
description, description1 belongs to DynamicSearchAds, how can i change these two fields?

thanks!

Google Ads API Forum Advisor Prod

unread,
Mar 5, 2020, 2:56:13 PM3/5/20
to ilmio...@gmail.com, adwor...@googlegroups.com
Hi Roberto,

That is just an example for you to base your code off of. You should replace it with DynamicSearchAd ad type and set the Description1 and Description2 fields to your desired value.

Roberto

unread,
Mar 16, 2020, 1:04:20 PM3/16/20
to AdWords API and Google Ads API Forum
 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;

  }

Google Ads API Forum Advisor Prod

unread,
Mar 16, 2020, 3:51:47 PM3/16/20
to ilmio...@gmail.com, adwor...@googlegroups.com
Hi Roberto,

Please see here for more information on that error. If you would like to change anything other than the status of the Ad, you will have to re-create the ad and remove the old one. I apologize for the confusion.

Roberto

unread,
Mar 17, 2020, 5:06:02 AM3/17/20
to AdWords API and Google Ads API Forum
Hi,
but in doing so this will destroy ads stats?

thanks again for your help!
R.

Google Ads API Forum Advisor Prod

unread,
Mar 17, 2020, 9:31:32 AM3/17/20
to ilmio...@gmail.com, adwor...@googlegroups.com
Hi Roberto,

You can still pull the stats of removed ads using the Ad Performance Report but you will not be able to "transfer" those stats to your new ad.
Reply all
Reply to author
Forward
0 new messages