jolicode / harvest-php-api

🌾 A Harvest API PHP Client
MIT License
22 stars 6 forks source link

Syntax Error in json parsing of time entries #15

Closed b3nl closed 4 years ago

b3nl commented 4 years ago

The serializer in ListTimeEntries::transformResponseBody throws a Symfony\Component\Serializer\Exception\NotEncodableValueException . The relevant stack trace is:y

at /var/www/html/releases/20200329065757/vendor/symfony/serializer/Encoder/JsonDecode.php:106 Symfony\Component\Serializer\Encoder\JsonDecode->decode() at /var/www/html/releases/20200329065757/vendor/symfony/serializer/Encoder/JsonEncoder.php:45 Symfony\Component\Serializer\Encoder\JsonEncoder->decode() at /var/www/html/releases/20200329065757/vendor/symfony/serializer/Encoder/ChainDecoder.php:40 Symfony\Component\Serializer\Encoder\ChainDecoder->decode() at /var/www/html/releases/20200329065757/vendor/symfony/serializer/Serializer.php:309 Symfony\Component\Serializer\Serializer->decode() at /var/www/html/releases/20200329065757/vendor/symfony/serializer/Serializer.php:140 Symfony\Component\Serializer\Serializer->deserialize() at /var/www/html/releases/20200329065757/vendor/jolicode/harvest-php-api/generated/Endpoint/ListTimeEntries.php:71 JoliCode\Harvest\Api\Endpoint\ListTimeEntries->transformResponseBody() at /var/www/html/releases/20200329065757/vendor/jane-php/open-api-runtime/Client/Psr7EndpointTrait.php:20 JoliCode\Harvest\Api\Endpoint\ListTimeEntries->parsePSR7Response() at /var/www/html/releases/20200329065757/vendor/jane-php/open-api-runtime/Client/Psr7HttplugClient.php:53 Jane\OpenApiRuntime\Client\Psr7HttplugClient->executePsr7Endpoint() at /var/www/html/releases/20200329065757/vendor/jolicode/harvest-php-api/generated/Client.php:809

xavierlacot commented 4 years ago

Hi @b3nl

It seems that the json returned by Harvest for this request could not be decoded. You can proceed the following way to debug:

$client = JoliCode\Harvest\ClientFactory::create(
  $accessToken,
  $harvestAccountId
);

$timeEntries = $client->listTimeEntries([], 'response');
dump($timeEntries->getBody()->getContents());

Could you please check that this is a valid json value?

xavierlacot commented 4 years ago

Hi @b3nl

Could you have a look at this? I tested this API call against some of my Harvest organizations, it seems to work smoothly.

b3nl commented 4 years ago

Yeah, i can't reproduce it constantly as well. It seems that single requests fail and that you kind of miss an error check before parsing the response.

xavierlacot commented 4 years ago

Closing, since several jane upgrades have been made since this report (and the library is successfully used in several projects)