Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create an Ad - Error: 3 INVALID_ARGUMENT #30

Closed
mattensor opened this issue Apr 16, 2019 · 3 comments
Closed

Can't create an Ad - Error: 3 INVALID_ARGUMENT #30

mattensor opened this issue Apr 16, 2019 · 3 comments
Labels
bug ⚠️ Something isn't working in the library

Comments

@mattensor
Copy link

Hey there

I'm having difficulty creating an Ad for my Ad Group, I did notice there was an issue where you would pass 2 enums into a create mutation - maybe somewhat related.

I'm using the latest package v1.2.2,

Below is the stack

// stack
ad params { ad_group: 'customers/4674531019/adGroups/74761353488',
  status: 3,
  ad:
   { final_urls: [ 'http://www.example.com' ],
     type: 3,
     name: 'best ad ever',
     expanded_text_ad:
      { headline_part_1: 'Cruise to Mars #%d',
        headline_part_2: 'Best Space Cruise Line',
        description: 'Buy your tickets now!',
        path_1: 'all-inclusive',
        path_2: 'deals' } } }
{ Error: The required field was not present in the resource.
    at AdGroupAdService.<anonymous> (/Users/matt/rea/rea-google-campaigns/node_modules/google-ads-api/build/services/service.js:142:23)
    at Generator.throw (<anonymous>)
    at rejected (/Users/matt/rea/rea-google-campaigns/node_modules/google-ads-api/build/services/service.js:5:65)
    at <anonymous>
  code:
   { requestError: 0,
     biddingStrategyError: 0,
     urlFieldError: 0,
     listOperationError: 0,
     queryError: 0,
     mutateError: 0,
     fieldMaskError: 0,
     authorizationError: 0,
     internalError: 0,
     quotaError: 0,
     adError: 0,
     adGroupError: 0,
     campaignBudgetError: 0,
     campaignError: 0,
     authenticationError: 0,
     adGroupCriterionError: 0,
     adCustomizerError: 0,
     adGroupAdError: 0,
     adSharingError: 0,
     adxError: 0,
     assetError: 0,
     biddingError: 0,
     campaignCriterionError: 0,
     collectionSizeError: 0,
     countryCodeError: 0,
     criterionError: 0,
     customerError: 0,
     dateError: 0,
     dateRangeError: 0,
     distinctError: 0,
     feedAttributeReferenceError: 0,
     functionError: 0,
     functionParsingError: 0,
     idError: 0,
     imageError: 0,
     languageCodeError: 0,
     mediaBundleError: 0,
     mediaFileError: 0,
     multiplierError: 0,
     newResourceCreationError: 0,
     notEmptyError: 0,
     nullError: 0,
     operatorError: 0,
     rangeError: 0,
     recommendationError: 0,
     regionCodeError: 0,
     settingError: 0,
     stringFormatError: 0,
     stringLengthError: 0,
     operationAccessDeniedError: 0,
     resourceAccessDeniedError: 0,
     resourceCountLimitExceededError: 0,
     adGroupBidModifierError: 0,
     contextError: 0,
     fieldError: 2,
     sharedSetError: 0,
     sharedCriterionError: 0,
     campaignSharedSetError: 0,
     conversionActionError: 0,
     conversionAdjustmentUploadError: 0,
     conversionUploadError: 0,
     headerError: 0,
     databaseError: 0,
     policyFindingError: 0,
     enumError: 0,
     keywordPlanError: 0,
     keywordPlanCampaignError: 0,
     keywordPlanNegativeKeywordError: 0,
     keywordPlanAdGroupError: 0,
     keywordPlanKeywordError: 0,
     keywordPlanIdeaError: 0,
     accountBudgetProposalError: 0,
     userListError: 0,
     changeStatusError: 0,
     feedError: 0,
     geoTargetConstantSuggestionError: 0,
     feedItemError: 0,
     labelError: 0,
     billingSetupError: 0,
     customerClientLinkError: 0,
     customerManagerLinkError: 0,
     feedMappingError: 0,
     customerFeedError: 0,
     adGroupFeedError: 0,
     campaignFeedError: 0,
     customInterestError: 0,
     extensionFeedItemError: 0,
     adParameterError: 0,
     feedItemValidationError: 0,
     extensionSettingError: 0,
     feedItemTargetError: 0,
     policyViolationError: 0,
     mutateJobError: 0,
     partialFailureError: 0,
     policyValidationParameterError: 0 },
  request:
   { customerId: '4674531019',
     operationsList: [ [Object] ],
     partialFailure: false,
     validateOnly: false },
  request_id: '_8Ph9A0hYxiAur6tzn6Qqw',
  failure:
   { Error: 3 INVALID_ARGUMENT: The required field was not present in the resource.
    at Object.exports.createStatusError (/Users/matt/rea/rea-google-campaigns/node_modules/grpc/src/common.js:91:15)
    at Object.onReceiveStatus (/Users/matt/rea/rea-google-campaigns/node_modules/grpc/src/client_interceptors.js:1204:28)
    at InterceptingListener._callNext (/Users/matt/rea/rea-google-campaigns/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/Users/matt/rea/rea-google-campaigns/node_modules/grpc/src/client_interceptors.js:618:8)
    at Object.grpc_1.default.ListenerBuilder.withOnReceiveStatus [as onReceiveStatus] (/Users/matt/rea/rea-google-campaigns/node_modules/google-ads-node/build/lib/interceptor.js:68:17)
    at InterceptingListener._callNext (/Users/matt/rea/rea-google-campaigns/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/Users/matt/rea/rea-google-campaigns/node_modules/grpc/src/client_interceptors.js:618:8)
    at Object.grpc_1.default.ListenerBuilder.withOnReceiveStatus [as onReceiveStatus] (/Users/matt/rea/rea-google-campaigns/node_modules/google-ads-node/build/lib/interceptor.js:151:13)
    at InterceptingListener._callNext (/Users/matt/rea/rea-google-campaigns/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/Users/matt/rea/rea-google-campaigns/node_modules/grpc/src/client_interceptors.js:618:8)
     code: 3,
     metadata: Metadata { _internal_repr: [Object] },
     details: 'The required field was not present in the resource.' } }

Here is my code which creates an Ad,

// service

export const createAd = async (ad: types.AdGroupAd) => {
  const response = await customer.adGroupAds.create(ad);
  return response.results;
};

// builder
import { createAd } from "../services/googleService";
import { types } from "google-ads-api";
import { AdGroupAdStatus, AdType } from "google-ads-node/build/lib/enums";

export const buildParamsForAd = adGroup => {
  /*eslint-disable @typescript-eslint/camelcase*/
  const ad: types.AdGroupAd = {
    ad_group: adGroup,
    status: AdGroupAdStatus.PAUSED,
    ad: {
      final_urls: ['http://www.example.com'],
      type: AdType.EXPANDED_TEXT_AD,
      name: 'best ad ever',
      expanded_text_ad: {
        headline_part_1: 'Cruise to Mars #%d',
        headline_part_2: 'Best Space Cruise Line',
        description: 'Buy your tickets now!',
        path_1: 'all-inclusive',
        path_2: 'deals'
      }
    },
  };

  return ad;
};

export const createGoogleAd = async adParams => {
  const adId = await createAd(adParams);

  return adId;
};

// cli
import minimist from "minimist";
import { buildParamsForAd, createGoogleAd } from "../ad/createAd";

// Example
// $ node dist/cli/createAdCli.js --adGroup "customers/4674531019/adGroups/74761353488"

const params = minimist(process.argv);
const adGroup: string = params["adGroup"];

const adParams = buildParamsForAd(adGroup);
console.log("ad params", adParams);

createGoogleAd(adParams)
  .then(data => console.log("ad:", data))
  .catch(err => console.log(err));

Not sure what argument is Invalid? Am I missing something here?

Help would be much appreciated,
Thanks :)

@madpilot
Copy link

On further investigation, we have a hypothesis that the expanded ad entity isn't being filled in complete. Looking at a dump of the operation object:

[ { wrappers_:
     { '1':
        { wrappers_:
           { '4':
              { wrappers_: null,
                messageId_: undefined,
                arrayIndexOffset_: -1,
                array: [ 'customers/4674531019/adGroups/74761353488' ],
                pivot_: 1.7976931348623157e+308,
                convertedFloatingPointFields_: {} },
             '5':
              { wrappers_:
                 { '2':
                    [ { wrappers_: null,
                        messageId_: undefined,
                        arrayIndexOffset_: -1,
                        array: [ 'http://www.example.com' ],
                        pivot_: 1.7976931348623157e+308,
                        convertedFloatingPointFields_: {} } ],
                   '7':
                    { wrappers_:
                       { '3':
                          { wrappers_: null,
                            messageId_: undefined,
                            arrayIndexOffset_: -1,
                            array: [ 'Buy your tickets now!' ],
                            pivot_: 1.7976931348623157e+308,
                            convertedFloatingPointFields_: {} } },
                      messageId_: undefined,
                      arrayIndexOffset_: -1,
                      array: [ <2 empty items>, [ 'Buy your tickets now!' ] ],
                      pivot_: 1.7976931348623157e+308,
                      convertedFloatingPointFields_: {} },
                   '23':
                    { wrappers_: null,
                      messageId_: undefined,
                      arrayIndexOffset_: -1,
                      array: [ 'best ad ever' ],
                      pivot_: 1.7976931348623157e+308,
                      convertedFloatingPointFields_: {} } },
                messageId_: undefined,
                arrayIndexOffset_: -1,
                array:
                 [ <1 empty item>,
                   [ [ 'http://www.example.com' ] ],
                   <2 empty items>,
                   3,
                   <1 empty item>,
                   [ <2 empty items>, [ 'Buy your tickets now!' ] ],
                   <2 empty items>,
                   [],
                   <5 empty items>,
                   [],
                   <6 empty items>,
                   [ 'best ad ever' ],
                   <2 empty items>,
                   [] ],
                pivot_: 1.7976931348623157e+308,
                convertedFloatingPointFields_: {} } },
          messageId_: undefined,
          arrayIndexOffset_: -1,
          array:
           [ <2 empty items>,
             3,
             [ 'customers/4674531019/adGroups/74761353488' ],
             [ <1 empty item>,
               [ [ 'http://www.example.com' ] ],
               <2 empty items>,
               3,
               <1 empty item>,
               [ <2 empty items>, [ 'Buy your tickets now!' ] ],
               <2 empty items>,
               [],
               <5 empty items>,
               [],
               <6 empty items>,
               [ 'best ad ever' ],
               <2 empty items>,
               [] ] ],
          pivot_: 1.7976931348623157e+308,
          convertedFloatingPointFields_: {} } },
    messageId_: undefined,
    arrayIndexOffset_: -1,
    array:
     [ [ <2 empty items>,
         3,
         [ 'customers/4674531019/adGroups/74761353488' ],
         [ <1 empty item>,
           [ [ 'http://www.example.com' ] ],
           <2 empty items>,
           3,
           <1 empty item>,
           [ <2 empty items>, [ 'Buy your tickets now!' ] ],
           <2 empty items>,
           [],
           <5 empty items>,
           [],
           <6 empty items>,
           [ 'best ad ever' ],
           <2 empty items>,
           [] ] ] ],
    pivot_: 1.7976931348623157e+308,
    convertedFloatingPointFields_: {} } ]

The only field in the expanded text field (id: 7) begin populated is the description field (id: 3). I would have expected five fields to have been populated?

This dump was found by adding console.log(util.inspect(operations, false, null, true)); to services/service.js (around line 108).

@kritzware
Copy link
Contributor

kritzware commented Apr 16, 2019

Hi @madpilot,

I've run some tests and you're definitely right, it looks like the ad is missing the expanded_text_ad fields (except for the description) when being created. I'm going to investigate further as to why this is happening and get back to you soon!

Thanks for reporting this.

Edit: The ad, with the missing expanded text ad fields:

{
  "resourceName": "",
  "status": 3,
  "adGroup": {
    "value": "customers/4674531019/adGroups/74761353488"
  },
  "ad": {
    "finalUrlsList": [
      {
        "value": "http://www.example.com"
      }
    ],
    "finalMobileUrlsList": [],
    "urlCustomParametersList": [],
    "type": 3,
    "devicePreference": 0,
    "urlCollectionsList": [],
    "name": {
      "value": "best ad ever"
    },
    "systemManagedResourceSource": 0,
    "expandedTextAd": {
      "description": {
        "value": "Buy your tickets now!"
      }
    }
  },
  "adStrength": 0
}

@kritzware kritzware added the bug ⚠️ Something isn't working in the library label Apr 16, 2019
@kritzware
Copy link
Contributor

We've released a fix for this issue and published a new version - 1.3.0. It was due to some bad camel case conversion in our google-ads-node library.

Make sure you update google-ads-api and your code above should now work! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ⚠️ Something isn't working in the library
Projects
None yet
Development

No branches or pull requests

3 participants