Creating Single Product Listing Groups Through Rest API

108 views
Skip to first unread message

ma...@danzrust.cz

unread,
May 23, 2023, 2:57:48 PM5/23/23
to Google Ads API and AdWords API Forum
Hi guys,
I'm trying to create new single product listing groups via Rest API but I'm just stuck - I don't know what mandatory information I need to provide. 

At this point, I am creating a new ad_group_criterion:

{
    "operations": [
        {
            "create": {
                "type": "LISTING_GROUP",
                "status": "ENABLED",
                "ad_group": "customers/7803661715/adGroups/149520355436",
                "cpc_bid_micros": 1000,
                "listing_group": {
                    "case_value": {
                        "product_item_id": {
                            "value": "shopify_fr_8211946045734_4473156881642"
                        }
                    }
                }
            }
        }
    ]
}

And I keep get back
{
    "type": "error",
    "array": "INVALID_ARGUMENT (400) Request contains an invalid argument. \n◉ The required field was not present."
}

Basically, my goal is to create the hierarchy shown in the attachment. 

Cam you pls advise?

G Ads Rest API.PNG

ma...@danzrust.cz

unread,
May 23, 2023, 5:16:20 PM5/23/23
to Google Ads API and AdWords API Forum
So I believe I'm getting close after recycling some of the older posts but something is still wrong.

Here is my currrent JSON:

{
    "operations": [
        {
            "create": {
                "type": "LISTING_GROUP",
                "status": "ENABLED",
                "adGroup": "customers/7803661715/adGroups/149870319335",
                "resourceName": "customers/7803661715/adGroups/149870319335~-1",
                "listingGroup": {
                    "type": "SUBDIVISION"
                }
            }
        },

        {
            "create": {
                "type": "LISTING_GROUP",
                "status": "ENABLED",
                "adGroup": "customers/7803661715/adGroups/149870319335",
                "cpcBidMicros": "10000",
                "listingGroup": {
                    "type": "UNIT",
                    "caseValue": {
                        "productItemId": {
                            "value": "shopify_fr_8211946045734_4473156881642"
                        }
                    },
                    "parentAdGroupCriterion": "customers/7803661715/adGroups/149870319335~-1"
                }
            }
        },

        {
            "create": {
                "type": "LISTING_GROUP",
                "status": "ENABLED",
                "adGroup": "customers/7803661715/adGroups/149870319335",
                "cpcBidMicros": "10000",
                "listingGroup": {
                    "type": "UNIT",
                    "caseValue": {
                        "productCondition": {}
                    }
                },
                "parentAdGroupCriterion": "customers/7803661715/adGroups/149870319335~-1"
            }
        }
    ]
}


==> My understanding is that first I need to create a subdivision and then create the one product I want to have + all other products, however when I ran this JSON,  I've been getting:

{
    "error": {
        "code": 400,
        "message": "Invalid JSON payload received. Unknown name \"parentAdGroupCriterion\" at 'operations[2].create': Cannot find field.",
        "status": "INVALID_ARGUMENT",
        "details": [
            {
                "@type": "type.googleapis.com/google.rpc.BadRequest",
                "fieldViolations": [
                    {
                        "field": "operations[2].create",
                        "description": "Invalid JSON payload received. Unknown name \"parentAdGroupCriterion\" at 'operations[2].create': Cannot find field."
                    }
                ]
            }
        ]
    }
}


################

Any ideas?

DZ

ma...@danzrust.cz

unread,
May 24, 2023, 3:55:34 PM5/24/23
to Google Ads API and AdWords API Forum
So I believe, I'm getting very close but now I'm stuck again.

This is my JSON:

{
    "operations": [

        {
            "create": {
                "type": "LISTING_GROUP",
                "status":"ENABLED",
                "adGroup": "customers/7803661715/adGroups/151093305002",
                "resourceName":"customers/7803661715/adGroups/151093305002~-1",

                "listingGroup": {
                    "type": "SUBDIVISION"
                }
            }
        },


        {
            "create": {
                "type": "LISTING_GROUP",
                "status": "ENABLED",
                "adGroup": "customers/7803661715/adGroups/151093305002",

                "cpcBidMicros": "10000",
                "listingGroup": {
                    "type": "UNIT",
                    "caseValue": {
                        "productItemId": {}
                    },
                    "parentAdGroupCriterion": "customers/7803661715/adGroups/151093305002~-1"

                }

            }
        },


        {
            "create": {
                "type": "LISTING_GROUP",
                "status": "ENABLED",
                "adGroup": "customers/7803661715/adGroups/151093305002",

                "cpcBidMicros": "10000",
                "listingGroup": {
                    "type": "UNIT",
                    "caseValue": {
                        "productItemId": {
                            "value": "shopify_fr_8211946045734_4473156881642"
                        }
                    },
                    "parentAdGroupCriterion": "customers/7803661715/adGroups/151093305002~-1"  
                }
            }
        }
    ]
}
######################################
######################################
######################################

Now I'm getting:
◉ Resource name 'customers/7803661715/adGroups/151093305002~-1' is malformed: expected 'customers/{customer_id}/adGroupCriteria/{ad_group_id}~{criterion_id}'. 

I've seen multiple posts where people would use the "~-1" trick while doing multiple operations at once but it was always in a different language (Java, Python etc.). 

How can I replicate the "~-1" the trick in the rest API? I see no mentions in the REST documentation.

I've also tried running the first operation to create root (the SUBDIVISION part in my code) to get the parentAdGroupCriterion for the two remaining create operations but that's not working either. When creating the SUBDIVISION, I'm getting error an error saying that "other group must be created" so it feels like I really need to do everything in one API call. 

DZ

Google Ads API Forum Advisor

unread,
May 25, 2023, 2:47:16 PM5/25/23
to ma...@danzrust.cz, adwor...@googlegroups.com

Hello,

Welcome to Google Ads API Support team. Thank you for reaching out to us.

With regards to your concern, it appears that the resource name in your request is malformed as it has adGroups instead of the expected adGroupCriteria.



Resource name 'customers/7803661715/adGroups/151093305002~-1' is malformed: expected 'customers/{customer_id}/adGroupCriteria/{ad_group_id}~{criterion_id}'. 



We would recommend that you follow this guidance https://developers.google.com/google-ads/api/rest/reference/rest/v13/customers.adGroupCriteria/mutate for your reference.

Let us know how it goes and if the issue persist, kindly provide to us the complete request and response logs with request id and request header generated on your end and we will be happy to look into it.

Note that these logs can be requested or provided to the developer handling the Google Ads API transactions when logging of the API requests has been enabled. You may check here (https://developers.google.com/google-ads/api/docs/best-practices/logging#client_library_logging) and click your client library for the specific guideline to enable it.

For REST interface requests, you can enable logging via the curl command by using the -i flag. This will cause the tool to include the HTTP response headers in the output.

Links to the highlighted words above:

 

This message is in relation to case "ref:_00D1U1174p._5004Q2lsXxy:ref"

Thanks,
 
Google Logo Google Ads API Team


ma...@danzrust.cz

unread,
May 25, 2023, 2:49:31 PM5/25/23
to Google Ads API and AdWords API Forum
Oh, damn, that might be it. I will try in a bit. I knew it was gonna be something super simple like this after seeing so many java/python hints.

DZ

Google Ads API Forum Advisor

unread,
May 25, 2023, 2:50:22 PM5/25/23
to ma...@danzrust.cz, adwor...@googlegroups.com

Hello,

In addition to our previous response. You may send the requested details privately via “Reply To Author” option. If that option is not available to you, send it directly to googleadsa...@google.com instead, and let us know here once it is provided.
 

ma...@danzrust.cz

unread,
May 25, 2023, 3:16:20 PM5/25/23
to Google Ads API and AdWords API Forum
Okay, so of course it works now but I do have a follow up question . I need to exclude the "everything else in All Products" listing group but the JSON is still generating both product groups as active. 

I was reading the REST documentation but could not find anything about the exclusions. I'm attaching what I am after.

{ "operations": [ { "create": { "type": "LISTING_GROUP", "status":"ENABLED", "adGroup": "customers/7803661715/adGroups/148252268534", "resourceName":"customers/7803661715/adGroupCriteria/148252268534~-1", "listingGroup": { "type": "SUBDIVISION" } } }, { "create": { "type": "LISTING_GROUP", "status": "PAUSED", "adGroup": "customers/7803661715/adGroups/148252268534", "cpcBidMicros": "10000", "listingGroup": { "type": "UNIT", "caseValue": { "productItemId": {} }, "parentAdGroupCriterion": "customers/7803661715/adGroupCriteria/148252268534~-1" } } }, { "create": { "type": "LISTING_GROUP", "status": "PAUSED", "adGroup": "customers/7803661715/adGroups/148252268534", "cpcBidMicros": "10000", "listingGroup": { "type": "UNIT", "caseValue": { "productItemId": { "value": "shopify_fr_8211946045734_4473156881642" } }, "parentAdGroupCriterion": "customers/7803661715/adGroupCriteria/148252268534~-1" } } } ] }

Exclusion.PNG

ma...@danzrust.cz

unread,
May 25, 2023, 4:55:36 PM5/25/23
to Google Ads API and AdWords API Forum
Okay.. Figured it out...:

{ "operations": [ { "create": { "type": "LISTING_GROUP", "status":"ENABLED", "adGroup": "customers/7803661715/adGroups/150631446858", "resourceName":"customers/7803661715/adGroupCriteria/150631446858~-1", "listingGroup": { "type": "SUBDIVISION" } } }, { "create": { "type": "LISTING_GROUP", "status": "PAUSED", "adGroup": "customers/7803661715/adGroups/150631446858", "negative": true, "listingGroup": { "type": "UNIT", "caseValue": { "productItemId": {} }, "parentAdGroupCriterion": "customers/7803661715/adGroupCriteria/150631446858~-1" } } }, { "create": { "type": "LISTING_GROUP", "status": "PAUSED", "adGroup": "customers/7803661715/adGroups/150631446858", "cpcBidMicros": "10000", "listingGroup": { "type": "UNIT", "caseValue": { "productItemId": { "value": "shopify_fr_8211946045734_4473156881642" } }, "parentAdGroupCriterion": "customers/7803661715/adGroupCriteria/150631446858~-1" } } } ] }

Google Ads API Forum Advisor

unread,
May 29, 2023, 3:14:58 PM5/29/23
to ma...@danzrust.cz, adwor...@googlegroups.com

Hi,

Thanks for getting back with us.

It seems that you already have figured out the answer to your concern. Can you confirm if you have any more questions regarding Google Ads API related concerns? If so, then don't hesitate to contact us.

ma...@danzrust.cz

unread,
May 29, 2023, 3:45:18 PM5/29/23
to Google Ads API and AdWords API Forum
Yep, it's all good now. Thanks for support.

DZ

Google Ads API Forum Advisor

unread,
Jun 1, 2023, 10:16:46 AM6/1/23
to ma...@danzrust.cz, adwor...@googlegroups.com

Hi DZ,

Thank you for the reply.

If you have additional questions that are specific with the Google Ads API(https://developers.google.com/google-ads/api/docs/start), feel free to send those over to our team and we would be happy to assist you further.



This message is in relation to case "ref:_00D1U1174p._5004Q2lsXxy:ref"

Punit Pushkar

unread,
Jul 5, 2023, 2:43:50 AM7/5/23
to Google Ads API and AdWords API Forum
Hey Guys, Can you help in how can I do the same process while only using the API and not the Rest API. 

Google Ads API Forum Advisor

unread,
Jul 5, 2023, 4:13:44 AM7/5/23
to punitpus...@gmail.com, adwor...@googlegroups.com

Hi Punit,

Thank you for reaching out to Google Ads API Forum.

Moving forward with your concern, you may try referring to this code example (https://developers.google.com/google-ads/api/samples/add-shopping-product-listing-group-tree) regarding Adding Shopping Product Listing Group Tree via client libraryThis example adds a shopping listing group tree to a shopping ad group. 

Let us know if you have further questions.
 

Reply all
Reply to author
Forward
0 new messages