Error Mutating AdGroupAd in AppCampaign

2020-03-18 Thread Diego Toro
Hello,

I am having issues updating an AdGroupAd in an AppCampain, in the first 
place I tried to update the status to Paused and got this response:

Status: Status{code=INVALID_ARGUMENT, description=Request contains an 
> invalid argument., cause=null}.
> 2020-03-18 16:21:52.108 ERROR 51088 --- [lTaskExecutor-3] c.i.m.m.u.p.g.
> GoogleAcAdsetUploadService : Error uploading adset
>   error_code {
> operation_access_denied_error: 
> OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE
>   }
>   message: "This operation is not permitted on this campaign type"
>   trigger {
> string_value: ""
>   }
>   location {
> field_path_elements {
>   field_name: "operations"
>   index {
>   }
> }
> field_path_elements {
>   field_name: "update"
> }
> field_path_elements {
>   field_name: "status"
> }
>   }
> }
>
>
> Also we need to change some headlines and descriptions within the same 
> adGroupAd:
>
com.google.ads.googleads.v2.errors.GoogleAdsException: errors {
  error_code {
request_error: IMMUTABLE_FIELD
  }
  message: "Field \'ad.app_ad.headlines\' cannot be modified by \'UPDATE\' 
operation."
  location {
field_path_elements {
  field_name: "operations"
  index {
  }
}
field_path_elements {
  field_name: "update"
}
field_path_elements {
  field_name: "ad"
}
field_path_elements {
  field_name: "app_ad"
}
field_path_elements {
  field_name: "headlines"
}
  }
}



Our question is, is there a way we can update an AppAd after created?

Also we tried removing the ad and creating a new one and seems like the 
adGroup get's broken, because the old ad and assets stay there and the new 
assets are added on top, but when you go to the edit page of the ad you 
still see the old headlines, descriptions, etc.

Is there documentation where this limitations are specified and how to 
handle them? where are taking as reference teh examples specified in: 
https://developers.google.com/google-ads/api/docs/client-libs

This is the string of the update operation without the ids for privacy:

resource_name: "customers//adGroupAds/~X"
status: PAUSED
ad_group {
  value: "customers/XXX/adGroups/"
}
ad {
  id {
value: X
  }
  type: APP_AD
  app_ad {
headlines {
  text {
value: "Changed Headline 3"
  }
}
headlines {
  text {
value: "Changed Headline 4"
  }
}
headlines {
  text {
value: "Changed Headline 5"
  }
}
descriptions {
  text {
value: "my description"
  }
}
  }
}

*Update mask:*
paths: "ad.app_ad.headlines"

Thank you very much
 

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/c5024e63-81b4-4136-bf51-9fa19f92a64a%40googlegroups.com.


Issue creating an Ad for App Campaign

2020-02-13 Thread Diego Toro
Hello I've been trying several ways to create an  Ad for App Campaign as 
described in: 

https://developers.google.com/google-ads/api/docs/app-campaigns/create-ad-group

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()) {