firstred / postnl-api-php

PostNL API PHP bindings
https://postnl-php.readthedocs.io
MIT License
26 stars 37 forks source link

Error `Deserializable entity `GetNearestLocationsResponse` contains unknown properties` #82

Closed BBrunekreeft closed 10 months ago

BBrunekreeft commented 1 year ago

When using GetNearestLocations() in BE or DE and no results are found, an exception is thrown. The message is: Deserializable entity 'GetNearestLocationsResponse' contains unknown properties: '['Date','Error','RequestId']'

Example:

$postnl = new PostNL($customer, $apikey, $sandbox);
$result = $postNL->getNearestLocations(
    (new GetNearestLocations())
        ->setCountrycode('DE')
        ->setLocation('70372')
);

This results in the following exception: Deserializable entity 'GetNearestLocationsResponse' contains unknown properties: '['Date','Error','RequestId']' in /var/www/html/test/vendor/firstred/postnl-api-php/src/Entity/AbstractEntity.php:253

The reponse returned by the PostNL API is

{
   "Date": "2023-07-24T09:45:27.9905231+00:00",
   "Error": {
      "ErrorCode": "0010",
      "ErrorMessage": "No results found."
   },
   "RequestId": "7be14e83-f9b0-4dc2-8324-64ceeb80993a"
}