JSON for creating the Ad

96 views
Skip to first unread message

f s

unread,
Jun 27, 2019, 5:51:40 AM6/27/19
to AdWords API and Google Ads API Forum
We're always grateful for Google Ads API Team's help.

Well, I'd like to create the Ad via curl, so I post the following JSON to: https://googleads.googleapis.com/v1/customers/5838476xxx/adGroupAds:mutate

{
     
'operations': {
       
'create': {
         
'status': 'ENABLED',
         
'ad_group': 'customers/5838476xxx/adGroups/75043676xxx',
         
'ad': {
           
'final_urls': ['https://www.foo.com/'],
           
'type': 'RESPONSIVE_SEARCH_AD',
           
'added_by_google_ads': true,
           
'name': 'New Ad 1'
         
}
       
}
     
}
   
}

I receive the following response:

{
 
"error": {
   
"status": "INVALID_ARGUMENT",
   
"message": "Request contains an invalid argument.",
   
"code": 400,
   
"details": [
     
{
       
"errors": [
         
{
           
"errorCode": {
             
"mutateError": "RESOURCE_NOT_FOUND"
           
},
           
"message": "Resource was not found.",
           
"trigger": {
             
"stringValue": "<null>"
           
},
           
"location": {
             
"fieldPathElements": [
               
{
                 
"index": "0",
                 
"fieldName": "operations"
               
},
               
{
                 
"fieldName": "create"
               
},
               
{
                 
"fieldName": "resource_name"
               
}
             
]
           
}
         
}
       
],
       
"@type": "type.googleapis.com/google.ads.googleads.v1.errors.GoogleAdsFailure"
     
}
   
]
 
}
}

What does "RESOURCE_NOT_FOUND" mean? Does it mean to add 'resource_name' above 'status'? But, I don't know how to write 'resource_name'.
For example, 

{
     
'operations': {
       
'create': {
         
'resource_name':'customers/5838476xxx/adGroupAds/75043676xxx~1',
         
'status': 'ENABLED',
         
'ad_group': 'customers/5838476xxx/adGroups/75043676xxx',
         
'ad': {
           
'final_urls': ['https://www.foo.com/'],
           
'type': 'RESPONSIVE_SEARCH_AD',
           
'added_by_google_ads': true,
           
'name': 'New Ad 1'
         
}
       
}
     
}
   
}

But, response is

{
 
"error": {
   
"status": "INVALID_ARGUMENT",
   
"message": "Request contains an invalid argument.",
   
"code": 400,
   
"details": [
     
{
       
"errors": [
         
{
           
"errorCode": {
             
"newResourceCreationError": "CANNOT_SET_ID_FOR_CREATE"
           
},
           
"message": "Do not set the id field while creating new resources.",
           
"trigger": {
             
"int64Value": "1"
           
},
           
"location": {
             
"fieldPathElements": [
               
{
                 
"index": "0",
                 
"fieldName": "operations"
               
},
               
{
                 
"fieldName": "create"
               
},
               
{
                 
"fieldName": "resource_name"
               
}
             
]
           
}
         
}
       
],
       
"@type": "type.googleapis.com/google.ads.googleads.v1.errors.GoogleAdsFailure"
     
}
   
]
 
}
}

What's wrong? Could you give me correct JSON code or a clue? I need your help.

Thanks.

Google Ads API Forum Advisor Prod

unread,
Jun 27, 2019, 4:51:12 PM6/27/19
to symb...@gmail.com, adwor...@googlegroups.com

Hi,

Thank you for reaching out. The RESOURCE_NOT_FOUND is usually seen if the resource is not formed correctly or is not available. Can you also include the asset resource and retry the request?
For the second concern, CANNOT_SET_ID_FOR_CREATE it looks like you are adding the AdGroupAd resource on the ad creation. If you’re creating a new Ad, this is not required. If you are updating an existing ad, the update field mask should be specified. Could you please give this a try and let us know if you have any issues?

Regards,
Nikisha Patel, Google Ads API Team



ref:_00D1U1174p._5001UCZnOo:ref

f s

unread,
Jun 28, 2019, 5:22:11 AM6/28/19
to AdWords API and Google Ads API Forum
Thank you, Nikisha.

Since I was fundamentally wrong, I'll set up another topic.

David Scott

unread,
Oct 15, 2020, 12:10:30 PM10/15/20
to AdWords API and Google Ads API Forum
'resourceName' works for me.
Reply all
Reply to author
Forward
0 new messages