product custom batch insert with no entries in response

714 views
Skip to first unread message
Message has been deleted

Kieron Thomas

unread,
Oct 14, 2014, 12:25:44 PM10/14/14
to google-content-...@googlegroups.com
Hi,

I've run a few test custom batch inserts, testing the json first in the API explorer. The two product inserted fine but I get no entries response. Below is just a var_dump of the getEntries() and then the entire response:

array (size=0)
  empty

object(Google_Service_ShoppingContent_ProductsCustomBatchResponse)[22147]
  protected 'entriesType' => string 'Google_Service_ShoppingContent_ProductsCustomBatchResponseEntry' (length=63)
  protected 'entriesDataType' => string 'array' (length=5)
  public 'kind' => string 'content#productsCustomBatchResponse' (length=35)
  protected 'collection_key' => string 'items' (length=5)
  protected 'modelData' => 
    array (size=1)
      'entries' => 
        array (size=0)
          empty
  protected 'processed' => 
    array (size=1)
      'entries' => boolean true

When the post fails it is also empty, I posted with an incorrect link url and could see the error I received in the API explorer. But nothing when I post using the API.

Am I missing something? I thought I should be receiving Entries data on success and failure.

I would be grateful for any help.

Kind regards,
Kieron

Yufeng Guo (Content API Team)

unread,
Oct 16, 2014, 11:20:08 AM10/16/14
to google-content-...@googlegroups.com
Hi Kieron,

I tried out a custom batch insert using the API explorer, and saw a success response that echoed the product I inserted. Are you not receiving that type of response in the API explorer, or is the problem only when you call the API directly from your own interface (some client library, presumably)?

Thanks,
Yufeng

Kieron Thomas

unread,
Oct 17, 2014, 4:59:59 AM10/17/14
to google-content-...@googlegroups.com
Hi Yufeng,

Thanks for the reply.

Apologies for confusion - I do get a response from the API explorer on success and failure.

I get no 'entries' response (I do get the 'kind' response) from the API directly for either success or failure. Even when using the exact same Json product data as used in the API explorer.

Kind regards,
Kieron

Yufeng Guo (Content API Team)

unread,
Oct 20, 2014, 1:30:37 PM10/20/14
to google-content-...@googlegroups.com
That is a very strange result. I have not encountered this before. May I ask what client library you are using to hit the API?

-Yufeng

Kieron Thomas

unread,
Oct 27, 2014, 7:26:00 AM10/27/14
to google-content-...@googlegroups.com
Hi Yufeng,

Again apologies for the delay, due to time constraints I've had to leave using the API and create a tab delimited file for FTP instead.

In answer, I used the Google PHP Client API which I downloaded from the link in the developers section of the site and using the API documentation for reference.

Even though I've switched to the FTP upload, I would still like to resolve the API issue if possible.

Kind regards,
Kieron

Yufeng Guo (Content API Team)

unread,
Oct 27, 2014, 2:43:51 PM10/27/14
to google-content-...@googlegroups.com
Hi Kieron,

I'll try out the PHP library specifically, but it's hard to know what aspect of the call I'm doing differently from you that is causing yours to error out. It would be interesting if any others in the forum who use the PHP client library could chime in with their experiences.

Thanks,
Yufeng

Kieron Thomas

unread,
Oct 28, 2014, 1:20:56 PM10/28/14
to google-content-...@googlegroups.com
Hi Yufeng,

Thanks - if it would help to have any of the code I've written, let me know. Maybe there's something glaring in there that I've missed.

Kind regards,
Kieron

Yufeng Guo (Content API Team)

unread,
Oct 29, 2014, 2:53:18 PM10/29/14
to google-content-...@googlegroups.com
Yeah if you have the code handy that might help, and if someone else on forum wanted to, they could chime in as well. 

Also, for your reference, this is our folder of php samples: https://github.com/googleads/googleads-shopping-samples/tree/master/php

Kieron Thomas

unread,
Oct 31, 2014, 5:59:23 AM10/31/14
to google-content-...@googlegroups.com
Hi Yufeng,

Actually I can see from the github samples where I'm going wrong - so don't worry I'll amend it and try again. Shame I didn't find those samples earlier.

Many thanks,
Kieron

David Tzau

unread,
Dec 14, 2014, 5:18:35 PM12/14/14
to google-content-...@googlegroups.com
Hi Yufeng, 

Hoping you can help.  I have exactly the same problem as Kieron but I'm using the Python client.  The API explorer works perfectly and the response comes back with the respective "entries" listed out.  However, when I use the exact same request using the API within my Python script, I get only the "kind" response.  "entries" is non-existent.

Below is the dump from the response:

{u'kind': u'content#productsCustomBatchResponse'}

Any help would be greatly appreciated

Yufeng Guo (Content API Team)

unread,
Dec 15, 2014, 1:54:53 PM12/15/14
to google-content-...@googlegroups.com
Are you using the python client out of the box? Do any other requests work for you? I would recommend trying a products.get instead of a custombatch if you are just getting started, to reduce the complexity of the request being sent, so it's easier to debug.

-Yufeng

David Tzau

unread,
Dec 16, 2014, 5:49:22 PM12/16/14
to google-content-...@googlegroups.com
Hi Yufeng,

Thanks for responding.  I am using the python client out of the box (v 1.3.1).  My other requests are working using a service account.   Here is some additional information about what is working, and what isn't.

Working API calls with valid responses:
products().get
inventory().set

However, when I use the products.custombatch() method to update a series of products in one call, I get the "kind" response only.  The API should be returning  "entries" so I can iterate through to find out what made it through, and what batch might have had an issue because of some error.  I tried using the API Explorer using the request below (scrubbed data for security reasons).  You'll notice I purposely put an empty string for the "gtin" attribute.  API Explorer returned a valid response with "entries".  However when I use the same JSON request in the python script I don't get the same response... only the "kind" value comes back:

    {
        "entries" :
        [
            {
                "batchId": 1,
                "merchantId" : "xxxxxxx",
                "method": "insert",
                "product":
                {
                    "id": "online:en:US:1234567",
                    "offerId": "1234567",
                    "title": "product title",
                    "description": "product description",
                    "link": "mywebsiteURL",
                    "imageLink": "myimageURL",
                    "contentLanguage": "en",
                    "targetCountry": "US",
                    "channel": "online",
                    "condition": "new",
                    "availability": "out of stock",
                    "brand": "aBrand",
                    "gtin": "",
                    "mpn": "manufacturePartNumber",
                    "price":
                    {
                        "currency": "USD",
                        "value": "123.9900"
                    },
                    "productType": "cat1 > cat2 > cat3",
                    "shippingWeight":
                    {
                        "unit": "lb",
                        "value": "0.0000"
                    },
                    "adwordsLabels":
                    ["A","B","C"],
                    "adwordsRedirect": "myAdwordsRedirect",
                    "customLabel0": "A",
                    "customLabel1": "B",
                    "customLabel2": "C",
                    "destinations":
                    [
                        {
                            "destinationName": "Shopping",
                            "intention": "required"
                        },
                        {
                            "destinationName": "ShoppingApi",
                            "intention": "required"
                        },
                        {
                            "destinationName": "AffiliateNetwork",
                            "intention": "required"
                        }
                    ]
                }
            }
        ]
    }

And got a valid response:
{
"kind": "content#productsCustomBatchResponse",
"entries": [
{
"kind": "content#productsCustomBatchResponseEntry",
"batchId": 1,
"errors": {
"errors": [
{
"domain": "content.ContentErrorDomain",
"reason": "validation",
"message": "[gtin] validation/invalid_value for DisplayAds,Shopping,ShoppingApi: Invalid GTIN value"
}
],
"code": 400,
"message": "[gtin] validation/invalid_value for DisplayAds,Shopping,ShoppingApi: Invalid GTIN value"
}
}
]
}

I noticed the samples on Github does not use products().custombatch to update a collection of batches, but queues up everything
https://github.com/davidtzau/googleads-shopping-samples/blob/master/python/product_insert_batch.py in a BatchHttpRequest object which I could give a shot, but I'd prefer to use custombatch and stick with what's available in the API to retrieve, insert, and delete products from GMC.

I'll keep plugging away. Any advice would be greatly appreciated.

Dave

Yufeng Guo (Content API Team)

unread,
Dec 19, 2014, 11:27:59 AM12/19/14
to google-content-...@googlegroups.com
thanks for the detailed description! I'll try to reproduce your issue in the library with some test data.

-Yufeng

David Tzau

unread,
Dec 21, 2014, 10:34:09 AM12/21/14
to google-content-...@googlegroups.com
Yufeng,

No need.  I finally figured this out.  Thanks for providing direction.   For the benefit of everyone else using products().custombatch the API's response is valid if you send in a valid JSON object.  Thanks to my stupidity, I had been sending in JSON strings which doesn't work.  JSON strings work well within the Google API explorer, but not within the Python script.  The problem is the API's response doesn't explicitly tell you that your body argument is invalid.  

So if you do this (which is obviously wrong):

jsonRequest = """
  {'hi' : 'there'}
"""

service.products().custombatch(body=jsonRequest, dryRun=True)

You get this as a response.
{"kind": "content#productsCustomBatchResponse"}

It looks like something worked, but in my case "entries" wasn't coming back.  

elementary mistake... but lesson learned.  

Thanks for your assistance Yufeng

Yufeng Guo (Content API Team)

unread,
Dec 22, 2014, 12:43:51 PM12/22/14
to google-content-...@googlegroups.com
Oh I see; very interesting. Are you using the python client library (https://github.com/google/google-api-python-client)? 

It looks like you can directly use python dictionaries in the request, and the client will serialize it to valid JSON for you: https://github.com/googleads/googleads-shopping-samples/blob/master/python/product_insert_batch.py

David Tzau

unread,
Dec 22, 2014, 2:33:07 PM12/22/14
to google-content-...@googlegroups.com
Yufeng,

I am using the python client library and you are correct.  Python's dictionaries and lists get serialized to valid JSON when making API calls.  It took me a while to wrap my head around this but finally saw the light.

It actually makes things very easy now as the entries" attribute value is really just a python list which makes it conducive to adding batch entries for product insert, get, or delete requests through a loop/iteration.

Vamshi Kiran

unread,
Jan 22, 2015, 9:11:47 AM1/22/15
to google-content-...@googlegroups.com
Hi Yufeng,

i am trying to send send batch request using Custom batch through API call. I My question is, what's is the limit of CustomBatch request. I mean how many product feeds can we send to CustomeBatch. 

Thanks,
Vamshi.

Yufeng Guo (Content API Team)

unread,
Jan 23, 2015, 3:16:39 AM1/23/15
to google-content-...@googlegroups.com

sujana narasimhan

unread,
Aug 21, 2023, 7:08:50 AM8/21/23
to Google Content API for Shopping
Hi Yufeng Guo,

Can we send more than 1000 entries for delete to  products.custombatch with method=delete?

Shopping API Forum Advisor

unread,
Aug 21, 2023, 8:45:49 AM8/21/23
to sujanana...@gmail.com, google-content-...@googlegroups.com
Hi,

Thank you for contacting the Content API support team.

I see that you have already raised this concern on another thread with the subject 'Google Content API method - custom.batch delete', and we have already responded there for this issue. To avoid multiple threads on the same issue, please take a look at that thread and continue the discussion on the same for further updates on the issue.

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

Thanks,
 
Google Logo Content API for Shopping Team

 

Reply all
Reply to author
Forward
0 new messages