From 977f9a4bcfd8a579941b4a7431a80d290f15c8df Mon Sep 17 00:00:00 2001 From: Marcus Laia Date: Wed, 5 Nov 2025 22:07:21 -0300 Subject: [PATCH] Fix FacebookResponse.is_success() method breaking with csv return --- facebook_business/api.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/facebook_business/api.py b/facebook_business/api.py index 095a9a3e7..685c806d1 100644 --- a/facebook_business/api.py +++ b/facebook_business/api.py @@ -85,12 +85,13 @@ def is_success(self): json_body = self.json() - if isinstance(json_body, collections_abc.Mapping) and 'error' in json_body: - # Is a dictionary, has error in it - return False - elif bool(json_body): - # Has body and no error + if bool(json_body) and isinstance(json_body, collections_abc.Mapping): + # Is a dictionary + if 'error' in json_body: + # Has 'error' as a key + return False if 'success' in json_body: + # Has 'success' as a key return json_body['success'] # API can return a success 200 when service unavailable occurs return 'Service Unavailable' not in json_body