Closed atrauzzi closed 10 years ago
Sure. Can you paste your request code here? In order to reproduce the issue it would be useful.
Seems that this kind of errors are because invalid associations for a given resource. If you try to get a "listing" with a "transaction" association (invalid association) it would fail.
$args = array(
'params' => array(
'listing_id' => 156326352
),
// A list of associations
'associations' => array(
// Could be a simple association, sending something like: ?includes=Images
'Transactions',
)
);
$result = $api->getListing($args);
print_r($result);
[error_messages] => Array
(
[0] => Access denied on association Transactions
)
But I'll add an exception if an error_messages is present on response.
I've just added a response exception on invalid associations errors. Please, try it and let me know ;)
FYI, EtsyResponseException
has a getResponse
to get the response. For example:
$args = array(
'params' => array(
'listing_id' => 156314224
),
// A list of associations
'associations' => array(
'Transactions',
)
);
try {
$result = $api->getListing($args);
} catch (Etsy\EtsyResponseException $e) {
echo "Error: " . $e->getMessage() . "\n";
echo "Response: " . print_r($e->getResponse(), true) . "\n";
}
Output:
Error: Invalid association: Access denied on association Transactions
Response: Array
(
[count] => 1
[results] => Array
(
[0] => Array
(
[listing_id] => 156314224
[state] => removed,
...
[error_messages] => Array
(
[0] => Access denied on association Transactions
)
)
)
[params] => Array
(
[listing_id] => 156314224
)
[type] => Listing
[pagination] => Array
(
)
)
Just issued a request and got the following return:
I'm wondering if the API should be detecting this and throwing an exception?