fix(api): handle different response formats in contact creation

This commit is contained in:
Fanilo-Nantenaina 2025-12-29 19:55:33 +03:00
parent ffb7a50443
commit 27c8ae77c2

10
api.py
View file

@ -2841,12 +2841,18 @@ async def creer_contact(numero: str, contact: ContactCreate):
contact.numero = numero contact.numero = numero
resultat = sage_client.creer_contact(contact.dict()) 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: except HTTPException:
raise raise
except Exception as e: 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)) raise HTTPException(500, str(e))