pownraj-anubavam / google-api-php-client

Automatically exported from code.google.com/p/google-api-php-client
Apache License 2.0
0 stars 0 forks source link

apiShoppingService throws "Invalid json in service response: {}" #136

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It appears that when a search result is empty, the api will throw an exception 
IF the fields parameter is included in the 'listProducts' method. It only 
throws the error if the query term produces no results.

So for example, the following code works fine:

$client = new apiClient();
$client->setApplicationName("My Application");
$client->setDeveloperKey({key});
$service = new apiShoppingService($client);
$results = $service->products->listProducts("public", array(
  'country' => "US",
  'q' => "832497623332"
));

What we get here is a result array that has omitted the 'items' value. This is 
the intended behavior.

This code does not work:

$client = new apiClient();
$client->setApplicationName("My Application");
$client->setDeveloperKey({key});
$service = new apiShoppingService($client);
$results = $service->products->listProducts("public", array(
  'country' => "US",
  'q' => "832497623332",
  'fields' => "items/product/title"
));

Here we expect the output to be the same, but instead it throws the "Invalid 
json in service response: {}" apiException error. The error message makes me 
think the issue resides in poorly handled empty json objects, but the fact it 
only occurs when the fields parameter is present makes me think the issue has 
something to do with trying to filter items that do not exist.

I'm using api client version 0.5.0
I'm using php version 5.2.17 on Linux running Apache 2.0

Original issue reported on code.google.com by bull.jus...@gmail.com on 31 May 2012 at 11:36

GoogleCodeExporter commented 9 years ago

Original comment by ianbar...@google.com on 22 Mar 2013 at 2:14

GoogleCodeExporter commented 9 years ago
ok

Original comment by jeevan.a...@gmail.com on 18 Nov 2013 at 6:42

Attachments:

GoogleCodeExporter commented 9 years ago
This issue tracker is now closing. Development on the Google PHP client library 
moved to GitHub with the release of the 1.0.0-alpha, and now the 1.0 branch has 
reached beta status there will be no further releases of the 0.6 branch of the 
library. 

Please take a look at the latest version on 
https://github.com/google/google-api-php-client

For information on migrating, please take a look at this guide: 
https://developers.google.com/api-client-library/php/guide/migration

For general library support please ask a question on StackOverflow: 
http://stackoverflow.com/questions/tagged/google-api-php-client

If you are looking for support with a specific API, please contact the team 
working with that API via StackOverflow or their preferred support mechanism. 

If your issue still exists with the new version of the library, please raise a 
bug in the GitHub issue tracker with a minimal code sample. 

Thanks!

Original comment by ianbar...@google.com on 22 Jan 2014 at 4:53