TypeError: Cannot find default value for object
I have a google ads script which is failing with the following error.
TypeError: Cannot find default value for object.
It seems fairly cryptic so im not sure what its referring to.
This is the line that its failing on:
var adOperation = adGroup.newAd().expandedTextAdBuilder() .newAd() .expandedTextAdBuilder() .withHeadline1(expandedTextAd.getHeadline1()) .withHeadline2(expandedTextAd.getHeadline2()) .withDescription1(expandedTextAd.getDescription1()) .withPath1(expandedTextAd.getPath1()) .withPath2(expandedTextAd.getPath2()) .withTrackingTemplate(expandedTextAd.getTrackingTemplate()) .withFinalUrl(expandedTextAd.getFinalUrl()) .build(adGroup);
I've checked adGroup is set and it is, not sure where to go from here.
Update:
I split the line in to each method call and the line which is failing is line 1
> var adOperation = adGroup .newAd() .expandedTextAdBuilder()
After a few hours head scratching, I fixed this by removing adGroup from the .build() method. build() doesn't take any parameters and I'm not sure why I was passing it. Still a very strange error.
var adOperation = adGroup .newAd() .expandedTextAdBuilder() .withHeadline1(expandedTextAd.getHeadline1()) .withHeadline2(expandedTextAd.getHeadline2()) .withDescription1(expandedTextAd.getDescription1()) .withPath1(expandedTextAd.getPath1()) .withPath2(expandedTextAd.getPath2()) .withTrackingTemplate(expandedTextAd.getTrackingTemplate()) .withFinalUrl(expandedTextAd.getFinalUrl()) .build();I would recommend anyone trying to solve anything similar to unchain the method calls and debug each call line by line.