Selector fields for both TextAd, ExpandedTextAd

2017-01-06 Thread Andy Lin
Can we have both TextAd and ExpandedTextAd in Adgroup?  If yes, can I use 
one selector to get all the ads (Both TextAd, ExpandedTextAd) for the 
adgroup, avoid to make 2 remote calls?

Selector selector = builder.fields(AdGroupAdField.Id, AdGroupAdField.
AdGroupId,AdGroupAdField.Headline, AdGroupAdField.
description1,AdGroupAdField.headlinePart1, AdGroupAdField.headlinePart2,
 AdGroupAdField.CreativeFinalUrls).orderAscBy(AdGroupAdField.AdGroupId) 

.offset(offset)

.equals(AdGroupAdField.Status, AdGroupAdStatus._ENABLED)

.in(AdGroupAdField.AdGroupId, predicateGroupIDs).limit(PAGE_SIZE).build();

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/165a4ae9-86c6-4d52-aa8b-66c565c816aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: can I use validateOnly=true in BatchJobService

2016-01-05 Thread Andy Lin
I understand this, but if I don't set validationOnly=true, the polling 
return me a batchJob object, if I set it to validationOnly=true, the 
polling return me null.  I am wondering if this is a bug ?  My polling 
method is a standard method from your web site documentation.

On Monday, January 4, 2016 at 5:42:33 PM UTC-5, Umesh Dengale wrote:
>
> Hello,
>
> The validationOnly 
> 
>  property 
> (true) will validate the request and will not perform the actual 
> operation and return the failing operations' errors if any. When a batch 
> job completes (validationOnly=false) with the DONE status then you could 
> download the results for each operation from the batch job's downloadUrl 
> .
>  
> Please check out the Download the batch job results and check for errors 
> 
>  section 
> from the Batch processing guide 
> .
>
> Thanks,
> Umesh, AdWords API Team.
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/4a1b44ca-938e-470d-8922-3191af495253%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


can I use validateOnly=true in BatchJobService

2016-01-04 Thread Andy Lin
I want to test my mutate requests in BatchJobService using 
validateOnly=true before submitting.  but I couldn't poll the job result 
using the batchId, it returns null from the following statement, is it 
possible to use validateOnly=true and test the mutate operations, and how 
can I poll the result?
BatchJobPage batchJobPage=batchJobService.get(selector);

this is my polling method, it is similar to the coding example.

private void pollJobResult(BatchJob batchJob,BatchJobServiceInterface 
batchJobService,BatchJobHelper batchJobHelper) throws Exception{

// Poll for completion of the batch job using an exponential back 
off.
int pollAttempts = 0;
boolean isPending = true;
Selector selector =
new SelectorBuilder()
.fields(BatchJobField.Id, BatchJobField.Status, 
BatchJobField.DownloadUrl,
BatchJobField.ProcessingErrors, 
BatchJobField.ProgressStats)
.equalsId(batchJob.getId())
.build();
do {
  long sleepSeconds = (long) Math.scalb(30, pollAttempts);
  logger.debug("Sleeping {} seconds...", sleepSeconds);
  
  Thread.sleep(sleepSeconds * 1000);
 
  BatchJobPage batchJobPage=batchJobService.get(selector);
  if (batchJobPage!=null){
  batchJob = batchJobPage.getEntries(0);
  
  logger.info("Batch job ID {} has status {}.", 
batchJob.getId(), batchJob.getStatus());
  pollAttempts++;
  isPending = PENDING_STATUSES.contains(batchJob.getStatus());
  }
} while (isPending && pollAttempts < MAX_POLL_ATTEMPTS);

if (isPending) {
  throw new TimeoutException(
  "Job is still in pending state after polling " + 
MAX_POLL_ATTEMPTS + " times.");
}

if (batchJob.getProcessingErrors() != null) {
  int i = 0;
  for (BatchJobProcessingError processingError : 
batchJob.getProcessingErrors()) {
  logger.error( "  Processing error {}: errorType={}, 
trigger={}, errorString={}, fieldPath={}"
  + ", reason=%s%n",
i++, processingError.getApiErrorType(), 
processingError.getTrigger(),
processingError.getErrorString(), 
processingError.getFieldPath(),
processingError.getReason()); 
  }
}

   /* if (batchJob.getDownloadUrl() != null && 
batchJob.getDownloadUrl().getUrl() != null) {
  BatchJobMutateResponse mutateResponse =
  
batchJobHelper.downloadBatchJobMutateResponse(batchJob.getDownloadUrl().getUrl());

 
 logger.info("Downloaded results from {}", 
batchJob.getDownloadUrl().getUrl());
  for (MutateResult mutateResult : 
mutateResponse.getMutateResults()) {
String outcome = mutateResult.getErrorList() == null ? 
"SUCCESS" : "FAILURE";
logger.info("  Operation {} - {}", mutateResult.getIndex(), 
outcome);  
  }
}*/

if (batchJob.getDownloadUrl() != null && 
batchJob.getDownloadUrl().getUrl() != null) {
BatchJobMutateResponse mutateResponse =

batchJobHelper.downloadBatchJobMutateResponse(batchJob.getDownloadUrl().getUrl());
System.out.printf("Downloaded results from %s:%n", 
batchJob.getDownloadUrl().getUrl());
for (MutateResult mutateResult : 
mutateResponse.getMutateResults()) {
  String outcome = mutateResult.getErrorList() == null ? 
"SUCCESS" : "FAILURE";
  StringBuilder stringBuilder=new StringBuilder();
  if (mutateResult.getErrorList()!=null){
  for (ApiError error: 
mutateResult.getErrorList().getErrors()){
  stringBuilder.append(error.getFieldPath()).append(" 
").append(error.getErrorString()).append("\n");
  }
  }
  logger.error("  Operation {} - status: {} reason:{} ", 
mutateResult.getIndex(), outcome, stringBuilder.toString());
}
  }
}

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discu

Re: adwords-axis-2.8.0.jar transitive dependencies cause Caused by: java.lang.ClassCastException: com.google.common.io.ByteSource$ByteArrayByteSource cannot be cast to com.google.common.io.InputSuppli

2015-12-28 Thread Andy Lin
Yes, it works after I excluded guava-jdk5-#.jar from all the google api. 
 My project also use google drive, oauth-client, and api-clients.  Some of 
these have the transitive dependency on guava-jdk5-#.jar

This is a example how I did it.

compile('com.google.api-client:google-api-client:1.20.0'){

exclude group: 'com.google.guava', module: 'guava-jdk5' 

}

compile('com.google.oauth-client:google-oauth-client-jetty:1.20.0'){

exclude group: 'com.google.guava', module: 'guava-jdk5' 

}

compile('com.google.apis:google-api-services-drive:v2-rev170-1.20.0'){

exclude group: 'com.google.guava', module: 'guava-jdk5' 

}

On Monday, December 14, 2015 at 8:58:24 AM UTC-5, Andy Lin wrote:
>
> In my build.gradle, I have those 2 adword api jars as dependencies, when I 
> pool the results from the batchJobs, I get the following execptions, which 
> versions of guava-#.jar and guava-jdk5-#.jar I should explicit specify in 
> my build.gradle?  It seems like transitive jar dependencies' version 
> conflict problems.  thanks for your answer
>
> compile('com.google.api-ads:ads-lib:2.8.0')
> compile('com.google.api-ads:adwords-axis:2.8.0')
>
>  if (batchJob.getDownloadUrl() != null && 
> batchJob.getDownloadUrl().getUrl() != null) {
> BatchJobMutateResponse mutateResponse =
> 
> batchJobHelper.downloadBatchJobMutateResponse(batchJob.getDownloadUrl().getUrl());
> System.out.printf("Downloaded results from %s:%n", 
> batchJob.getDownloadUrl().getUrl());
> for (MutateResult mutateResult : 
> mutateResponse.getMutateResults()) {
>   String outcome = mutateResult.getErrorList() == null ? 
> "SUCCESS" : "FAILURE";
>   System.out.printf("  Operation [%d] - %s%n", 
> mutateResult.getIndex(), outcome);
> }
>   }
>  
>
>
> Caused by: java.lang.ClassCastException: 
> com.google.common.io.ByteSource$ByteArrayByteSource cannot be cast to 
> com.google.common.io.InputSupplier
> at 
> com.google.common.io.MultiInputStream.advance(MultiInputStream.java:65) 
> ~[guava-jdk5-13.0.jar:na]
> at 
> com.google.common.io.MultiInputStream.(MultiInputStream.java:44) 
> ~[guava-jdk5-13.0.jar:na]
> at 
> com.google.common.io.ByteSource$ConcatenatedByteSource.openStream(ByteSource.java:653)
>  
> ~[guava-19.0-rc2.jar:na]
> at 
> com.google.api.ads.adwords.axis.utils.AxisDeserializer.buildWrappedInputStream(AxisDeserializer.java:160)
>  
> ~[adwords-axis-2.8.0.jar:na]
> at 
> com.google.api.ads.adwords.axis.utils.AxisDeserializer.deserializeBatchJobMutateResults(AxisDeserializer.java:113)
>  
> ~[adwords-axis-2.8.0.jar:na]
> at 
> com.google.api.ads.adwords.axis.utils.v201509.batchjob.BatchJobHelper.downloadBatchJobMutateResponse(BatchJobHelper.java:101)
>  
> ~[adwords-axis-2.8.0.jar:na]
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/92ae31b8-1e89-46ee-9e18-fd53dbbe43db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


adwords-axis-2.8.0.jar transitive dependencies cause Caused by: java.lang.ClassCastException: com.google.common.io.ByteSource$ByteArrayByteSource cannot be cast to com.google.common.io.InputSupplier

2015-12-14 Thread Andy Lin
In my build.gradle, I have those 2 adword api jars as dependencies, when I 
pool the results from the batchJobs, I get the following execptions, which 
versions of guava-#.jar and guava-jdk5-#.jar I should explicit specify in 
my build.gradle?  It seems like transitive jar dependencies' version 
conflict problems.  thanks for your answer

compile('com.google.api-ads:ads-lib:2.8.0')
compile('com.google.api-ads:adwords-axis:2.8.0')

 if (batchJob.getDownloadUrl() != null && 
batchJob.getDownloadUrl().getUrl() != null) {
BatchJobMutateResponse mutateResponse =

batchJobHelper.downloadBatchJobMutateResponse(batchJob.getDownloadUrl().getUrl());
System.out.printf("Downloaded results from %s:%n", 
batchJob.getDownloadUrl().getUrl());
for (MutateResult mutateResult : 
mutateResponse.getMutateResults()) {
  String outcome = mutateResult.getErrorList() == null ? 
"SUCCESS" : "FAILURE";
  System.out.printf("  Operation [%d] - %s%n", 
mutateResult.getIndex(), outcome);
}
  }
 


Caused by: java.lang.ClassCastException: 
com.google.common.io.ByteSource$ByteArrayByteSource cannot be cast to 
com.google.common.io.InputSupplier
at 
com.google.common.io.MultiInputStream.advance(MultiInputStream.java:65) 
~[guava-jdk5-13.0.jar:na]
at 
com.google.common.io.MultiInputStream.(MultiInputStream.java:44) 
~[guava-jdk5-13.0.jar:na]
at 
com.google.common.io.ByteSource$ConcatenatedByteSource.openStream(ByteSource.java:653)
 
~[guava-19.0-rc2.jar:na]
at 
com.google.api.ads.adwords.axis.utils.AxisDeserializer.buildWrappedInputStream(AxisDeserializer.java:160)
 
~[adwords-axis-2.8.0.jar:na]
at 
com.google.api.ads.adwords.axis.utils.AxisDeserializer.deserializeBatchJobMutateResults(AxisDeserializer.java:113)
 
~[adwords-axis-2.8.0.jar:na]
at 
com.google.api.ads.adwords.axis.utils.v201509.batchjob.BatchJobHelper.downloadBatchJobMutateResponse(BatchJobHelper.java:101)
 
~[adwords-axis-2.8.0.jar:na]

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/68fac3cb-d73f-43a9-9096-2184a56c4652%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.