google-ads-api icon indicating copy to clipboard operation
google-ads-api copied to clipboard

Cannot perform mutations that set nullable fields to `null`

Open nnattawat opened this issue 3 years ago • 4 comments

I could not find the way to update bid_modifier of campaign_cirterion to null

When I use the following code to update campaign_criterion's bid_modifier, it works when I provide a number value. However, I cannot set it to null.

const resource = new GoogleResources.CampaignCriterion({
    resource_name: ResourceNames.campaignCriterion(CUSTOMER_ID, CAMPAIGN_ID, CAMPAIGN_CRITERION_ID),
    bid_modifier: null,
})

const results = await customer.campaignCriteria.update([resource])

I have tried to set it to null via Google Ads REST API endpoint directly without this lib and it works. Not sure is the an issue with the lib?

I use v10.0.2 of this lib.

nnattawat avatar Jun 22 '22 03:06 nnattawat

we are getting same issue as well.

anjith-sm avatar Jun 22 '22 04:06 anjith-sm

@nnattawat @anjith-sm This is one of the main failings of this library. We are unable to discern between nullable and non-nullable fields, and therefore by default we do not allow fields to be set to null. In the case of bid modifiers there is a work-around. Setting a bid modifier to 1 has the same effect as setting it to null. There will be a difference in the Google Ads UI, but the effect on an ads account is the same.

wcoots avatar Jun 23 '22 08:06 wcoots

@WillCooter Thanks for responding. I'm assuming this can't be fixed and will continue to behave the same in future versions as well?

anjith-sm avatar Jun 23 '22 14:06 anjith-sm

@anjith-sm For the time being this will remain an issue. A fix would have to involve compiling a list of resource attributes that can be null, and adapting the whole API including the parsing methods. Unfortunately this is not something that either myself or @kritzware have time to do at present due to our other commitments at Opteo. However it is certainly something that we would like to fix in the future

wcoots avatar Jun 24 '22 10:06 wcoots