mrdulin/nodejs-google-adwords

AdError.CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR

mrdulin opened this issue · 1 comments

operation: Update the status of multiple ad group ads.

error:

soap:Client: [AdError.CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR @ operations[0].operand.ad, AdError.CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR @ operations[1].operand.ad]: {"ApiExceptionFault":{"message":"[AdError.CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR @ operations[0].operand.ad, AdError.CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR @ operations[1].operand.ad]","ApplicationException.Type":"ApiException","errors":[{"attributes":{"xsi:type":"AdError"},"fieldPath":"operations[0].operand.ad","fieldPathElements":[{"field":"operations","index":0},{"field":"operand"},{"field":"ad"}],"trigger":"","errorString":"AdError.CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR","ApiError.Type":"AdError","reason":"CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR"},{"attributes":{"xsi:type":"AdError"},"fieldPath":"operations[1].operand.ad","fieldPathElements":[{"field":"operations","index":1},{"field":"operand"},{"field":"ad"}],"trigger":"","errorString":"AdError.CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR","ApiError.Type":"AdError","reason":"CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR"}]}}

test case:

  it('#update', async () => {
    const ads: IAd[] = [
      {
        id: '331943088184',
        attributes: {
          'xsi:type': 'ExpandedTextAd'
        }
      },
      {
        id: '331195148581',
        attributes: {
          'xsi:type': 'ExpandedTextAd'
        }
      }
    ];
    const adGroupId = '72029524744';
    const adGroupAds: IAdGroupAd[] = ads.map((ad: IAd) => {
      const adGroupAd: IAdGroupAd = {
        adGroupId,
        ad,
        status: AdGroupAd.Status.ENABLED
      };
      return adGroupAd;
    });

    const actualValue = await adGroupAdService.update(adGroupAds);
  });

error doc: https://developers.google.com/adwords/api/docs/common-errors#AdError.CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR

  it('#update', async () => {
    const ads: IAd[] = [
      {
        id: '331943088184'
      },
      {
        id: '331195148581'
      }
    ];
    const adGroupId = '72029524744';
    const adGroupAds: IAdGroupAd[] = ads.map((ad: IAd) => {
      const adGroupAd: IAdGroupAd = {
        adGroupId,
        ad,
        status: AdGroupAd.Status.ENABLED
      };
      return adGroupAd;
    });

    const actualValue = await adGroupAdService.update(adGroupAds);
  });

Solution: remove the attributes, then it works fine.

Update the status for ad group ad.

Before:

image

After:

image