diff --git a/frappe/integrations/utils.py b/frappe/integrations/utils.py index 09907ba784..bb4f62463b 100644 --- a/frappe/integrations/utils.py +++ b/frappe/integrations/utils.py @@ -21,15 +21,15 @@ def make_request(method: str, url: str, auth=None, headers=None, data=None, json ) response.raise_for_status() - content_type = response.headers.get("content-type") - if content_type == "text/plain; charset=utf-8": - return parse_qs(response.text) - elif content_type.startswith("application/") and content_type.split(";")[0].endswith("json"): - return response.json() - elif response.text: - return response.text - else: - return + # Check whether the response has a content-type, before trying to check what it is + if content_type := response.headers.get("content-type"): + if content_type == "text/plain; charset=utf-8": + return parse_qs(response.text) + elif content_type.startswith("application/") and content_type.split(";")[0].endswith("json"): + return response.json() + elif response.text: + return response.text + return except Exception as exc: if frappe.flags.integration_request_doc: frappe.flags.integration_request_doc.log_error()