From 27c8ae77c22fa23c5c844eded3e96cabeacb3079 Mon Sep 17 00:00:00 2001 From: Fanilo-Nantenaina Date: Mon, 29 Dec 2025 19:55:33 +0300 Subject: [PATCH] fix(api): handle different response formats in contact creation --- api.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/api.py b/api.py index d08fd3c..e9d5510 100644 --- a/api.py +++ b/api.py @@ -2841,12 +2841,18 @@ async def creer_contact(numero: str, contact: ContactCreate): contact.numero = numero resultat = sage_client.creer_contact(contact.dict()) - return Contact(**resultat) - + + if isinstance(resultat, dict) and "data" in resultat: + contact_data = resultat["data"] + else: + contact_data = resultat + + return Contact(**contact_data) + except HTTPException: raise except Exception as e: - logger.error(f"Erreur création contact: {e}") + logger.error(f"Erreur création contact: {e}", exc_info=True) raise HTTPException(500, str(e))