Opteo / google-ads-api

Google Ads API client library for Node.js
https://opteo.com
MIT License
270 stars 90 forks source link

Error when remove using mutation resource #459

Closed khangho2511 closed 1 year ago

khangho2511 commented 1 year ago

const campaignOperations = [ { entity: 'campaign_criterion', operation: 'remove', resource: { resource_name: 'customers/1248315497/campaignCriteria/20305843423~116505648784' } }] const campaignResponse: services.MutateGoogleAdsResponse = await subCustomer.mutateResources( campaignOperations, { response_content_type: enums.ResponseContentType.MUTABLE_RESOURCE, }, ); this error happen: {"errors":[{"error_code":{"request_error":"RESOURCE_NAME_MALFORMED"},"message":"Resource name '[object Object]' is malformed: expected 'customers/{customer_id}/campaignCriteria/{campaign_id}~{criterion_id}'.","location":{"field_path_elements":[{"field_name":"mutate_operations","index":0},{"field_name":"campaign_criterion_operation"},{"field_name":"remove"}]}}],"request_id":"-jFJSFbpbkfb1-hCcRevCg"}

wcoots commented 1 year ago

Hi @khangho2511, the problem here is you are passing an object to the resource key of campaignOperations. Instead simply pass the resource name as a string, e.g.

const campaignOperations = [{
    entity: 'campaign_criterion',
    operation: 'remove',
    resource: 'customers/1248315497/campaignCriteria/20305843423~116505648784' // this line has changed
}]
wcoots commented 1 year ago

Also I would advise using fake ids in future when making issues, not necessarily data you want to expose to the public...