I am migrating code from v13 to v2009.  One portion of my application
is used to add ImageAds to multiple Campaigns and AdGroups at once.
I'm interested in rewriting the code to take advantage of the
validateOnly capability, so that I can validate all the ads before
trying to add them, and report back to the user for any validation
errors.

I'm looking for some code samples that use validation like this (in
Java).  I see the simple example on the AdWords API Blog about the
validateOnly header, but I am not sure how to adapt it for a more
general and robust use case.  I can do some trial-and-error coding,
but before I do that, I'm sure that someone else has already done it,
and so I'd love to piggy back on that.

The first issue is that I don't want to have to test the inner
ApiError to see if it is one of about 25 specific subclasses, in order
to let the user know what kind of thing went wrong.  Probably I will
just report back the ApiErrorType field, which is common to all,
although it would be nice to be able to get at the more specific
"reason" field that exists in some of the subclasses.  Is there a
recommended way to deal with this issue?

The second issue is that it is not clear to me how to match up the
ApiError in the ApiException.getErrors array with the particular Ad
that fails validation.  Let's say I pass in 10 Ad objects to mutate
(using the Validation version of the service), and the Ad in position
3 doesn't pass for some reason.  Will the getErrors array have just
one ApiError (assuming all other Ads were fine), and if so how can I
tell which Ad it applies to?  Also, is it possible to have multiple
ApiErrors for a single Ad, for example if it has multiple problems?
Again I am not sure how to match up the error(s) with the offending Ad
(s).  I can see that the "fieldPath" property would be useful here,
but I don't want to write an OGNL parser to deal with it, although
there may be a simpler way of using this information that I haven't
thought of.  I could restructure my code to only try one Ad at a time,
so that it is clear what Ad the errors apply to, but then I get more
round-trips and more latency.  What is the recommended way to handle
this issue?

--

You received this message because you are subscribed to the Google Groups 
"AdWords 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.


Reply via email to