浏览代码

log whatsapp web json

root 8 月之前
父节点
当前提交
af86bc3015
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      models/whatsapp_message.py

+ 5 - 1
models/whatsapp_message.py

@@ -129,7 +129,11 @@ class WhatsAppMessage(models.Model):
 
             # Verificando si la respuesta contiene data->id
             if response.status_code == 200:
-                response_json = response.json()
+                try:
+                    response_json = response.json()
+                except ValueError:
+                    _logger.error("La respuesta no es JSON válido: %s", response.text)
+                    response_json = {}
                 if "_data" in response_json and "id" in response_json["_data"]:
                     _logger.info(f"Petición exitosa. ID: {response_json['_data']['id']['id']}")
                     whatsapp_message.write({