I keep getting UNEXPECTED_INTERNAL_API_ERROR and I am not able to tell what the error possible could be ?
session.setClientCustomerId(accountId);
String KEY_TO_EXTRACT_PRODUCT_TYPE = "value=";
if (partitionTree == null) {
partitionTree = ProductPartitionTree.createAdGroupTree(adWordsServices, session, adGroupId);
}
//get the root from the tree
ProductPartitionNode root = partitionTree.getRoot();
ProductPartitionNode subDivisionNode;
// get root as subdivision as that is the actionable object
String adwordsProductType = "";
for (ProductPartitionNode node: root.getChildren()) {
// We are trying to extract the correct product type on adwords. This is because there are times when
// the product type in our SQL DB is different from that on adwords because of encoding issues. Example - (notice the difference in dash)
// '[global] small electrics – body weight scales' (on adwords) and '[global] small electrics - body weight scales' (on SQL DB)
if (node.getDimension().toString().contains(KEY_TO_EXTRACT_PRODUCT_TYPE)) {
// this is to extract the product type value from a string like 'ProductType{productDimensionType=ProductType, type=PRODUCT_TYPE_L1, value=[global] storage and org - [closet storage] baskets boxes & buckets}'
adwordsProductType = node.getDimension().toString().substring(node.getDimension().toString().indexOf(KEY_TO_EXTRACT_PRODUCT_TYPE) + KEY_TO_EXTRACT_PRODUCT_TYPE.length());
adwordsProductType = adwordsProductType.substring(0, adwordsProductType.indexOf('}'));
break;
}
}
root = root.asSubdivision();
//adding or fetching the subdivision from the root
if (!adwordsProductType.equals(productType)) {
log.error(String.format("Product Type of ad groups was changed from %s to %s", productType, adwordsProductType));
productType = adwordsProductType;
}
subDivisionNode = root.getChild(ProductDimensions.createType(PRODUCT_TYPE_L1, productType)).asSubdivision();
ProductDimension itemProductDimenion = ProductDimensions.createOfferId(itemId);
itemProductDimenion.setProductDimensionType(PRODUCT_OFFER_ID);
// A check to ensure that the item id exists.
if (!subDivisionNode.hasChild(itemProductDimenion)) {
log.error(String.format("Missing: ItemId %s not found.\n", itemId));
plasNotFound.add(recordId);
} else {
//adding the child node to the subdivision
subDivisionNode.removeChild(itemProductDimenion);
}
}