Can't create ads using mutate in google ads API call (Using CURL not client library)

877 views
Skip to first unread message

ProMotive Car

unread,
Mar 9, 2021, 8:34:43 AM3/9/21
to AdWords API and Google Ads API Forum
Hi
I'm researching google ads API and started to work out the whole ad create process via API (only using CURL not using client library).

As per documentation, we should use mutate for CREATE/UPDATE/REMOVE operations for an endpoint. In the way, I've created campaign budget, campaign, adgroups successfully via API mutate operation. However, I'm trying to create an ad. But I'm facing some issues while creating that.

Here I'll explain two cases which I've tried.

1. First I've used mutate create operation for google ads endpoint.
With the corresponding request body.
But I got the following error.
Invalid JSON payload received. Unknown name \"create\" at 'operations[0]': Cannot find field.
As per this error, I thought, we don't have create mutate for ads API. So I've tried adGroupAds endpoint.

Request Body

{
  "operations": [
    {
    "create": {
        "status": "PAUSED",
        "ad": {
            "final_urls": "https://developers.google.com/",
            "name": "My Test ad"
        },
        "ad_group": "customers/{customer_id}/adGroups/{adGroupId}"
      }
    }
  ]
}

But I got resource not found error. I've also passed the resource_name param in the request body in the following ways
1. "resource_name": "customers/{customer_id}/adGroupAds/{adGroupId}/-1",
2. "resource_name": "customers/{customer_id}/adGroupAds/{adGroupId}~-1"

I'm not what I'm missing and how to create an ad using CURL. Please help me to overcome this. I'm not having a proper example for this endpoint in the API documentation using CURL. It will be more helpful if you help me with the sample request body, endpoint CURL, and what are the necessary params should be passed for the endpoint.

Thanks in advance.

Google Ads API Forum Advisor Prod

unread,
Mar 9, 2021, 10:58:08 PM3/9/21
to promot...@promotivecar.com, adwor...@googlegroups.com
Hi,

Thank you for posting your concern.

Please see my answer below for each item:
1. Create operation is not supported in AdService, with this, you need to use the AdGroupAdService instead for creating ads.

2. As discussed on the Key Point section of this document on constructing create operation in REST API, you don't need to specify a resourceName or ID and this is the possible reason why the error occurred. With this, please try not setting resourceName in the API request.

Also, our team doesn't have sample CURL for your use-case and you will need to follow this document in order to construct API quest. Let me know if you have further questions.

Regards,
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


ref:_00D1U1174p._5004Q2DMN7A:ref
Message has been deleted
Message has been deleted

Google Ads API Forum Advisor Prod

unread,
Mar 11, 2021, 10:54:11 PM3/11/21
to promot...@promotivecar.com, adwor...@googlegroups.com
Hi,

I would like to inform you that I am going to remove your latest post on this forum thread as it contains generated logs. Please refrain from attaching generated API logs on forum.

Moving forward, according to this document of create operation of the AdGroupAdOperation, no resource name is expected for the new ads so the error should not be encountered in the API request that you've sent. However, so that I can further check the issue, could you provide the complete request and response logs generated on your end especially with request ID?

Please ensure to provide it via Reply privately to author option for privacy purposes.
Reply all
Reply to author
Forward
0 new messages